DEV Community

Discussion on: ES6 for beginners with example

Collapse
 
zazulame profile image
Michael Zazula

In two of your examples I think you reference the wrong variable.

let SumElements = (arr) => {
console.log(arr); // [10, 20, 40, 60, 90]
let sum = 0;
for (let element of arr) {
sum += arr;
}
console.log(sum); // 220.
}
SumElements([10, 20, 40, 60, 90]);

As well as in the following example of for of loops.

Collapse
 
srebalaji profile image
Srebalaji Thirumalai

Thank you. I updated :) :)