Suppose we have an array of numbers: let numbers = [20,10,52,25]
.
To get the sum we usually use a for loop and traverse through the list right. You can easily do that using the reduce array function.
let numbers = [20, 10, 52, 25];
const sum = numbers.reduce((a, b) => a+b)
console.log("Sum is", sum)
// Sum is 107
Please if you know another way to do this, please let me know in the comments below ✌️