Skip to content

Instantly share code, notes, and snippets.

@rashid327
Created February 26, 2020 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rashid327/70e6a0c12617f778010e701b3414fe64 to your computer and use it in GitHub Desktop.
Save rashid327/70e6a0c12617f778010e701b3414fe64 to your computer and use it in GitHub Desktop.
JS forEash
<script>
var sum = 0;
var numbers = [91, 2, 4, 45, 65, 32, 49];
numbers.forEach(myFunction);
function myFunction(item) {
sum += item;
document.getElementById("demo").innerHTML = sum;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment