/* Given a time in 12-hour AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00 AM on a 12-hour clock and 00:00:00 on a 24-hour clock. Noon is 12:00:00 PM on 12-hour clock and 12:00:00 on 24-hour clock Examples: Input : A single string containing a time in 12-hour clock format(hh:mm:ss AM or hh:mm:ss PM where 01 <= hh <= 12 or 01 <= mm,ss <= 59 Output :Convert and print the given time in 24-hour format, where 00 <= hh <= 23 Input : 07:05:45PM Output : 19:05:45 */ const timein24hrs = (hh, mm, ss, pmoram) => { if (hh === 12 && mm === 00 && ss === 00 && pmoram === "AM" ) { return "00" + ":" + "00" + ":" + "00"; } else if (hh === 12 && mm === 00 && ss === 00 && pmoram === "PM" ) { return "12" + ":" + "00" + ":" + "00"; } else if (hh >= 1 && hh < 12 && pmoram === "PM") { return (hh + 12) + ":" + mm + ":" + ss; } else if (hh >= 12 && pmoram === "AM") { return (hh - 12) + ":" + mm + ":" + ss; } return hh + ":" + mm + ":" + ss; }; console.log(timein24hrs(12,00,00,"PM")); console.log(timein24hrs(12,00,00,"AM")); console.log(timein24hrs(12,45,00,"AM")); console.log(timein24hrs(12,40,00,"PM")); console.log(timein24hrs(01,00,00,"AM")); console.log(timein24hrs(01,01,06,"PM"));