In this video I calculate the sum of an array using the function reduce()
Code in the video:
const arr = [1, 2, 3, 4];
//The first argument is the callback function
//The second argument is the initial value
const arrSum = arr.reduce(sum, 0);
//The function called by reduce()
function sum(total, current) {
return total + current;
}
console.log(arrSum);
#Shorts #programming #coding #javascript
Sur cette page du site, vous pouvez voir la vidéo en ligne Javascript reduce() turns an array into a single value durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Noah Öberg 23 juillet 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 106 fois et il a aimé 1 téléspectateurs. Bon visionnage!