Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const firstPlayer = 'x';
- const secondPlayer = 'circle';
- const board = document.getElementById('board');
- const cells = document.getElementsByClassName('cell');
- let currentPlayer = null;
- function addClickListeners() {
- for (let i = 0; i < cells.length; i++) {
- const currentCell = cells[i];
- currentCell.addEventListener('click', );
- }
- }
- function chooseRandomPlayer() {
- const rnd = Math.random();
- if (rnd < 0.5) {
- currentPlayer = firstPlayer;
- } else {
- currentPlayer = secondPlayer;
- }
- board.classList.add(currentPlayer);
- }
- window.onload = function() {
- chooseRandomPlayer();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement