console.log(
[].reduce((a, b) => a + b)
)
// 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
//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);