Skip to content

Instantly share code, notes, and snippets.

@chisumo2016
Created November 8, 2016 10:26
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 chisumo2016/c2919ca27278c37149c586948a10135e to your computer and use it in GitHub Desktop.
Save chisumo2016/c2919ca27278c37149c586948a10135e to your computer and use it in GitHub Desktop.
JavaScript boilerplate
<!DOCTYPE html>
<html>
<body>
<p>Click the button to list all the items in the array.</p>
<button onclick="numbers.forEach(myFunction)">Try it</button>
<p id="demo"></p>
<script>
demoP = document.getElementById("demo");
var numbers = [4, 9, 16, 25];
function myFunction(item, index) {
demoP.innerHTML = demoP.innerHTML + "index[" + index + "]: " + item + "<br />";
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment