Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let counterWin = 0;
- let winIndex = null;
- for (let i = 0; i < WINNING_COMBINATION.length; i++) {
- counterWin = 0;
- indexWin = null;
- for (let index of WINNING_COMBINATION[i]) {
- if (cellElements[index].classList.contains(CIRCLE_CLASS)) {
- counterWin++;
- } else if (cellElements[index].classList.length != 2) {
- winIndex = index;
- }
- if (counterWin == 2) {
- if (winIndex == null) {
- continue;
- }
- break;
- }
- }
- if (winIndex != null && counterWin == 2) {
- break;
- }
- }
- return counterWin == 2 ? winIndex : null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement