Skip to content
View kennyblack92's full-sized avatar

Block or report kennyblack92

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
kennyblack92/README.md
<title>XOXO Game</title> <style> body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f0f0; } .game { display: grid; grid-template-columns: repeat(3, 100px); grid-template-rows: repeat(3, 100px); gap: 10px; border: 2px solid #000; padding: 10px; background-color: #fff; } .cell { width: 100px; height: 100px; border: 1px solid #000; display: flex; justify-content: center; align-items: center; font-size: 24px; font-weight: bold; cursor: pointer; } .cell:hover { background-color: #ddd; } .game-over { background-color: rgba(255, 0, 0, 0.5); } </style>
<script> const cells = []; const gameOver = () => { for (let i = 0; i < 3; i++) { if (cells[i * 3].textContent === cells[i * 3 + 1].textContent && cells[i * 3].textContent === cells[i * 3 + 2].textContent && cells[i * 3].textContent !== '') { return true; } if (cells[i].textContent === cells[i + 3].textContent && cells[i].textContent === cells[i + 6].textContent && cells[i].textContent !== '') { return true; } } if (cells[0].textContent === cells[4].textContent && cells[0].textContent === cells[8].textContent && cells[0].textContent !== '') { return true; } if (cells[2].textContent === cells[4].textContent && cells[2].textContent === cells[6].textContent && cells[2].textContent !== '') { return true; } return false; }; const draw = () => { for (let i = 0; i < 9; i++) { if (cells[i].textContent === '') { return false; } } return true; }; const resetGame = () => { for (let i = 0; i < 9; i++) { cells[i].textContent = ''; } }; const handleCellClick = (cell) => { if (cell.textContent === '') { cell.textContent = 'X'; if (gameOver()) { document.querySelector('.game').classList.add('game-over'); } else if (draw()) { alert('Draw!'); resetGame(); } else { cell.textContent = 'O'; if (gameOver()) { document.querySelector('.game').classList.add('game-over'); } else if (draw()) { alert('Draw!'); resetGame(); } } } }; const createGame = () => { const game = document.querySelector('.game'); for (let i = 0; i < 9; i++) { const cell = document.createElement('div'); cell.classList.add('cell'); cell.textContent = ''; cell.addEventListener('click', () =>

Popular repositories Loading

  1. EXCEL-BOT EXCEL-BOT Public

    TEST PROJECT

    JavaScript 3 2

  2. raganork-md raganork-md Public

    Forked from souravkl11/raganork-md

    Multi-functional WhatsApp bot project

    JavaScript 2 1

  3. BLACK-HAT BLACK-HAT Public

    JavaScript 2 2

  4. deploy-raganork deploy-raganork Public

    Forked from sou6av/deploy-raganork

    Dockerfile 1

  5. IZUKU-MD IZUKU-MD Public

    Forked from excelottah6/IZUKU-MD

    JavaScript 1

  6. NEMESIS NEMESIS Public

    Forked from GARRITv/NEMESIS

    JavaScript 1