Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started