Last active
October 12, 2022 21:04
-
-
Save lorenzofelletti/03fc8e521a2bf1705c3c14ff2426d37a to your computer and use it in GitHub Desktop.
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
function playPause() { | |
let playing = true; | |
return () => { // () => is equivalent to function() ...in this case | |
if (playing) | |
console.log("now stopped"); | |
else | |
console.log("now playing"); | |
playing = !playing; | |
} | |
} | |
document.getElementById('btn').onclick = playPause(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment