Sum of Array
let arr = [1,2,3];
let sum = arr.reduce((acc,cur) => acc+cur ,0);
console.log(sum);
forEach
Iterate an array. It takes a callback function with element, index, and array itself.
Array.forEach( (element,index,array) =>
{ console.log(element,index,array) }
);
const str = ['apple','orange','pear'];
str.forEach( ele => console.log(ele.toUpperCase()) );
Output: APPLE
ORANGE
PEAR