Playlist length
Turn seconds into the 3:05 and 1:02:05 times music apps show, then add up a whole playlist from its track lengths.
Write two functions.
formatDuration(seconds) returns the time the way a music app shows it: minutes and two-digit seconds (185 gives "3:05"), and once there is at least an hour, hours too, with two-digit minutes (3725 gives "1:02:05").
playlistLength(tracks) takes tracks like { title: "Neon Rain", length: "3:25" } and returns the total, formatted the same way.
JavaScript
playlistLength([{ title: "Neon Rain", length: "3:25" }, { title: "Late Bus", length: "4:40" }]);
// "8:05"Checks
- Minutes and seconds
- Hours
- Add up a playlist
exercise_1.js to run
function formatDuration(seconds) {
}
function playlistLength(tracks) {
}