Programming is my hobby. I enjoy solving problems and dealing with difficulties.
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS)
HH = hours, padded to 2 digits, range: 00 - 99MM = minutes, padded to 2 digits, range: 00 - 59SS= seconds, padded to 2 digits, range: 00 - 59The maximum time never exceeds 359999 (99:59:59)
function humanReadable(seconds) {
let hh = String('0' + Math.trunc(seconds / 60 / 60)).slice(-2);
let mm = String('0' + Math.trunc(seconds / 60 % 60)).slice(-2);
let ss = String('0' + Math.trunc(seconds % 60 % 60)).slice(-2);
return `${hh}:${mm}:${ss}`;
}