https://codepen.io/gaearon/pen/gWWZgR?editors=0010
- Display the location for each move in the format (col, row) in the move history list.
function getColRow(i) {
function col(i) {
const one = new Set([0, 3, 6])
const two = new Set([1, 4, 7])
const three = new Set([2, 5, 8])
if (one.has(i)) {
return 1
} else if (two.has(i)) {
return 2
} else if (three.has(i)) {
return 3
}
}
function row(i) {
if (i <= 2) {
return 1
} else if (i <= 5) {
return 2
} else {
return 3
}
}
return "col: " + col(i) + "row: " + row(i)
}
- Bold the currently selected item in the move list.
- Rewrite Board to use two loops to make the squares instead of hardcoding them.
- Add a toggle button that lets you sort the moves in either ascending or descending order.
- When someone wins, highlight the three squares that caused the win.
- When no one wins, display a message about the result being a draw.