How JavaScript's Array Reduce Works - #JavaScript30 18/30

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

You are genius, thank you. I learnt a lot from this tutorial.

rotrose
Автор

another great way
const measuredTime = new Date(null);

const MHSTime = measuredTime.toISOString().substr(11, 8); "04:58:58"

antonbodnia
Автор

How do you have the gutter symbols? Looks like a Git package, or is this Atom?

MatthewPeck_personal
Автор

WITH REDUCE
const timeNodes =

let seconds = timeNodes.reduce( (total, current, index) => {
let [min, sec] =
return total += min * 60 + sec;
}, 0);

let hour = seconds / 3600 <= 1 ? 0 : Math.floor(seconds / 3600);
let min = Math.floor( (seconds % 3600) / 60 );
let sec = (seconds % 3600) % 60;
console.log(hour, min, sec);

anonim
Автор

but why are we doing only floor and not ceil ? Will it be wrong if we do ceil ?

snehasamuel
Автор

I wrote a function that takes in seconds' result and returns totalVidTime. Great video! learning a ton with this series.

function totalVidTime(seconds){
let hours =Math.floor(seconds/3600);
let minutes
let secnd =
return
}

jaimeandrescarcamosepulved
Автор

Without .map and parseFloat():

const seconds = timeNodes.reduce((total, currValue) => {
const [mins, secs] =
return total + (mins * 60 + secs * 1);
}, 0);

margaritabozhenova
Автор

At 5:36. (mins*60)+(secs*1). would have done the trick

jean-francoisbouzereau