From 67aa16ea36fa6770593bb99135669f7e6f9c36fd Mon Sep 17 00:00:00 2001 From: Cool-Katt Date: Tue, 9 Apr 2024 13:12:33 +0300 Subject: [PATCH] Lint & format --- .../state-of-tic-tac-toe/.meta/proof.ci.js | 26 ++++++++++--------- .../state-of-tic-tac-toe.spec.js | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/proof.ci.js b/exercises/practice/state-of-tic-tac-toe/.meta/proof.ci.js index 1fb80498e4..ac6750df6d 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/proof.ci.js +++ b/exercises/practice/state-of-tic-tac-toe/.meta/proof.ci.js @@ -1,7 +1,7 @@ export const gamestate = (board) => { let gridSize = board.length; - let numberOfX = board.join('').match(/X/g)?.length ?? 0 - let numberOfO = board.join('').match(/O/g)?.length ?? 0 + let numberOfX = board.join('').match(/X/g)?.length ?? 0; + let numberOfO = board.join('').match(/O/g)?.length ?? 0; let scorringArray = Array(gridSize * 2 + 2).fill(null); let boardAsNumbers = board .map((row) => @@ -17,23 +17,25 @@ export const gamestate = (board) => { let [row, col] = [Math.floor(index / gridSize), index % gridSize]; scorringArray[row] += Number(element); scorringArray[gridSize + col] += Number(element); - (row === col) && (scorringArray[2 * gridSize] += Number(element)); - (gridSize - 1 - col === row) && (scorringArray[2 * gridSize + 1] += Number(element)); + row === col && (scorringArray[2 * gridSize] += Number(element)); + gridSize - 1 - col === row && + (scorringArray[2 * gridSize + 1] += Number(element)); }); switch (true) { case numberOfX - numberOfO > 1: - throw new Error('Wrong turn order: X went twice') + throw new Error('Wrong turn order: X went twice'); case numberOfX - numberOfO < 0: - throw new Error('Wrong turn order: O started') + throw new Error('Wrong turn order: O started'); case scorringArray.includes(gridSize) && scorringArray.includes(-gridSize): - throw new Error('Impossible board: game should have ended after the game was won') + throw new Error( + 'Impossible board: game should have ended after the game was won', + ); case scorringArray.includes(gridSize) || scorringArray.includes(-gridSize): - return 'win' - case boardAsNumbers.includes('0'): - return 'ongoing' + return 'win'; + case boardAsNumbers.includes('0'): + return 'ongoing'; default: - return 'draw' + return 'draw'; } }; - diff --git a/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe.spec.js b/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe.spec.js index 8f9bd755e6..04e77b3ef3 100644 --- a/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe.spec.js +++ b/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe.spec.js @@ -196,7 +196,7 @@ describe('Invalid boards', () => { const expected = new Error( 'Impossible board: game should have ended after the game was won', ); - const actual = () => gamestate(board); + const actual = () => gamestate(board); expect(actual).toThrow(expected); }); });