adding numbers in an array javascript
console.log(
[].reduce((a, b) => a + b)
)
adding numbers in an array javascript
console.log(
[].reduce((a, b) => a + b)
)
js sum of array
[1, 2, 3, 4].reduce((a, b) => a + b, 0)
// Output: 10
add numbers in array
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
add numbers from array nodejs
//these are the values//
var values = [
'1',
'2'
]
//makes a variable named total, adding together the values
var total = values[0] + values[1]
//prints out the variable named total
console.log(total);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us