suma wszystkich liczb w tablicy JavaScript
const arrSum = arr => arr.reduce((a,b) => a + b, 0)
TechWhizKid
const arrSum = arr => arr.reduce((a,b) => a + b, 0)
console.log(
[].reduce((a, b) => a + b)
)
const sum = arr => arr.reduce((a, b) => a + b, 0);
// how to add numbers in an array in javascript
let number = [10, 20, 40];
let result = number.reduce((a, b) => a + b);
console.log(result); // 70
const years = [1, 2, 3, 4]
let total = 0;
for (let i = 0; i < years.length; i++) {
total += years[i]
}
console.log(total)
//answer willl be 10