Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Time Converter (24h to 12h) solution in Clear category for Time Converter (24h to 12h) by Atadolfo
import assert from "assert";
var timeConverter = (dayTime: string): string => dayTime.split(":").map((n: string, i: number, v: string[]) => !i ? (Number(n) % 12)||12 : n + (Number(v[0]) < 12 ? " a.m." : " p.m.")).join(":");
console.log('Example:')
console.log(timeConverter('12:30'))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(timeConverter('12:30'), '12:30 p.m.')
assert.equal(timeConverter('09:00'), '9:00 a.m.')
assert.equal(timeConverter('23:15'), '11:15 p.m.')
console.log("Coding complete? Click 'Check' to earn cool rewards!");
May 21, 2020
Comments: