JavaScript – Array forEach examples
In JavaScript, we can use forEach(function) to loop an Array. The provided function in forEach() will run once for each array element. var total = 0; var num = [1, 2, 3, 4, 5]; num.forEach(anyFunction) function anyFunction(data){ total += data; } console.log(total); //15 var words = ""; var num = ["a", "b", "c", "d", "e"]; […]