Created
February 1, 2019 23:58
-
-
Save gmelodie/24a83cdd8cb45b9c189c818d0a0d0f47 to your computer and use it in GitHub Desktop.
Javascript for choosing player on tic-tac-toe
This file contains hidden or 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
<script type="text/javascript"> | |
let ex = true; | |
let oh = false; | |
function computePlay(buttonId) { | |
let divId = "div_"+buttonId; | |
let playSymbol; | |
if (ex) { | |
playSymbol = 'X'; | |
} else if (oh) { | |
playSymbol = 'O'; | |
} | |
document.getElementById(divId).innerHTML = playSymbol; | |
ex = !ex; | |
oh = !oh; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment