[javascript] Javascript: convert 24-hour time-of-day string to 12-hour time with AM/PM and no timezone

Here's a few variations that will work.

_x000D_
_x000D_
const oneLiner = (hour = "00", min = "00", sec = "00") => `${(hour % 12) || 12}:${("0" + min).slice(-2)}:${sec} ${(hour < 12) ? 'am' : 'pm'}`_x000D_
console.log('oneliner', oneLiner(..."13:05:12".split(":")))_x000D_
_x000D_
_x000D_
_x000D_
const oneLinerWithObjectInput = ({hour = "00", min = "00", sec = "00"} = {}) => `${(hour % 12) || 12}:${("0" + min).slice(-2)}:${sec} ${(hour < 12) ? 'am' : 'pm'}`_x000D_
console.log('onelinerWithObjectInput', oneLinerWithObjectInput({_x000D_
   hour: "13:05:12".split(":")[0],_x000D_
   min: "13:05:12".split(":")[1],_x000D_
   sec: "13:05:12".split(":")[2]_x000D_
}))_x000D_
_x000D_
_x000D_
const multiLineWithObjectInput = ({hour = "00", min = "00", sec = "00"} = {}) => {_x000D_
   const newHour = (hour % 12) || 12_x000D_
       , newMin  = ("0" + min).slice(-2)_x000D_
       , ampm    = (hour < 12) ? 'am' : 'pm'_x000D_
   return `${newHour}:${newMin}:${sec} ${ampm}`_x000D_
}_x000D_
console.log('multiLineWithObjectInput', multiLineWithObjectInput({_x000D_
   hour: "13:05:12".split(":")[0],_x000D_
   min: "13:05:12".split(":")[1],_x000D_
   sec: "13:05:12".split(":")[2]_x000D_
}))
_x000D_
_x000D_
_x000D_