/* golf */ const toTwelveHour = time => { const [hr,min] = time.split(':'); return `${hr>12?hr-12:hr==0?12:hr}:${min}${hr>12?'PM':'AM'}`; } /* expanded utility */ const toTwelveHour = (time) => { const [hour, min] = time.split(':'); const suffix = hour > 12 ? 'PM' : 'AM'; const hr = hour > 12 ? hour - 12 : parseInt(hour, 10); return `${hr === 0 ? 12 : hr}:${min}${suffix}`; };