Question: Javascript 12 hours time to 24 hours---- what am i doing wrong? sample input 07:05:45PM sample output 19:05:45 function timeConversion(s) { let h1 let h2

Javascript 12 hours time to 24 hours---- what am i doing wrong?

sample input 07:05:45PM 

sample output

19:05:45 

function timeConversion(s) { let h1 let h2 = 0 let h3 if(s[8]==='A'){ if(parseInt(s[0]) === 0){ h1 = s[1]+s[2]+s[3]+s[4]+s[5]+s[6]+s[7]; }else h1 = s[0]+s[1]+s[2]+s[3]+s[4]+s[5]+s[6]+s[7]; return h1 }else if(s[8]==='P'){ h2 = h2 +parseInt(s[1]) if(parseInt(s[0])===1){ h2 = 10 + h2 +12 }else{ h2 = 12+h2 } h3 = h2+s[2]+s[3]+s[4]+s[5]+s[6]+s[7] return h3 }else{ } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!