You are viewing a single comment's thread. Return to all comments →
My solution in javascript :
function timeConversion(s) { // Write your code here const ampm = s.slice(-2) const h = s.slice(0,2) const rest = s.slice(2,-2) // console.log(n) // 12 // console.log(t) // "PM" if ( ampm === "PM" ) { return h === "12" ? `12${rest}` : `${String(Number(h) + 12)}${rest}` } else { return h === "12" ? `00${rest}` : `${h}${rest}` } }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
My solution in javascript :