This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="myButton"> Hello World! </button> | |
<script> | |
var button = document.getElementById("myButton") | |
function speak(){ alert("hi!") } // this is a function declaration, allowing 'speak' to be used anywhere in the code, even above this line. | |
//you can also assign an "anonymous function" to a variable name, but this function can only be called below where it was assigned | |
//var speak = function() { alert("hi!") } | |
button.onclick = speak | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment