Untitled
unknown
javascript
2 years ago
568 B
3
Indexable
class GameMaster { player.placeMarker() // Do other stuff here } class Player { placeMarker(squareIndex) { square.markerPlaced = squareIndex } } class Square { markerPlaced = null; } // index.html <ul> <li class="square"></li> <li class="square"></li> <li class="square"></li> <li class="square"></li> <li class="square"></li> </ul> <script> const squares = document.querySelectorAll('.square') squares.forEeach(square => { square.addEventListener('click', getIndexOfSquare); }) </script>
Editor is loading...
Leave a Comment