You are viewing a single comment's thread. Return to all comments →
function timeConversion(s) { // Write your code here let sustitute = ""; let newtime = ""; // Debugging // s = "12:01:00PM" if (s.includes("AM")){ if (s.substring(0,2) === "12"){ sustitute = "00" } } if (s.includes("PM")){ // 1 - 11 if(s[0]=== "0" || s[0]=== "1" && s[1] !== "2" ){ sustitute = `${Number(s.substring(0,2)) + 12}` } } newtime = sustitute !== "" ? newtime = s.replace(`${s[0]}${s[1]}`, `${sustitute}`) : s ; return newtime.replace(`${s[8]}${s[9]}`, ""); }
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 →