New project #203464
Replies: 2 comments 1 reply
|
Thank you for your interest in contributing to our community! We currently only accept discussions created through the GitHub UI using our provided discussion templates. Please re-submit your discussion by navigating to the appropriate category and using the template provided. This discussion has been closed because it was not submitted through the expected format. If you believe this was a mistake, please reach out to the maintainers. |
|
you did a good job as a beginner. what id like to improve there is that there are repeating code like d1.innerText up to d9.innerText, which you can create a loop to iterate those boxes. you can also create a function for your boxes event listener like function markzxc(box, index, symbol, color, boolTurn0) {
board[index] = symbol;
box.innerText = symbol;
box.style.color = color;
turn0 = boolTurn0;
change_turn();
return;
}then d1.addEventListener("click", () => {
if (board[0] != "E") {
alert("Box is marked already");
} else {
if (turn0 == true) {
markzxc(d1, 0, "O", "red", false);
} else {
markzxc(d1, 0, "X", "green", true);
}
check_condition();
}
});actually you can also loop those event listeners of yours, so its much more cleaner. just think if there are repeating code, maybe you can make a function for it, or loop it to make it look cleaner. you should also validate that if the game has a winner, then players should not be able to click a box and add a symbol. all goods. this is how i also code when i was a beginner. keep it up. you might also want to learn |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone!
I recently built my first frontend project—a simple Tic Tac Toe game using HTML, CSS, and JavaScript.
I'm currently learning frontend development, so I'd really appreciate any feedback. If you were reviewing this project, what would you improve?
I'd love to hear your thoughts. Thanks for taking a look
https://github.com/vidub04/tic_tac_toe_game
All reactions