Hướng dẫn thử thách
1 / 1
Build a Tic-Tac-Toe Game
**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab.
**User Stories:**
1. You should create a `Board` component that renders nine `button` elements each with a class of `square` in a 3x3 grid.
2. Clicking `button.square` elements should alternate between displaying an `X` then `O` within the element.
3. Once a player has won the game, clicking on any `button.square` should not cause any further changes.
4. You should create a `button#reset` element that resets the game when clicked.
5. A message should be displayed indicating the winner in the format `Winner: X` or `Winner: O`, or neither if the result is a draw.
# --before-all--
```js
let clock = __FakeTimers.install();
async function reset(assert) {
const reset = document.querySelector("#reset");
assert.exists(reset, "button#reset should exist");
reset.click();
clock.tick(50);
}
// Gets the text of the document excluding that of the matching selector.
function getInnerTextExcept(removingSelector) {
const body = document.body.cloneNode(true);
const squareElements = body.querySelectorAll(`${removingSelector},script`);
squareElements.forEach(element => {
element.parentNode.removeChild(element)
});
return body.innerText;
}
```
# --after-all--
```js
clock.uninstall();
```
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.sh
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵