You are viewing a single comment's thread. Return to all comments →
this is my solution but it doesn't work on hackerrank editor but it's working properly on my machine
function timeConversion(s) { //for PM if(s[8] === "P"){ if(s.slice[0,2]== "12"){ return(s.slice[0,8]); }else{ let new_hour = String(Number(s.slice[0,2]) + 12); return(new_hour + s.slice[2,8]); } } //for AM else if(s[8] === "A"){ if(s.slice[0,2]== "12"){ let new_hour = String(Number(s.slice[0,2]) - 12); return(new_hour + s.slice[2,8]); }else{ return(s.slice[0,8]); } } }
Time Conversion
You are viewing a single comment's thread. Return to all comments →
this is my solution but it doesn't work on hackerrank editor but it's working properly on my machine