}
function highlightWord(word, value, onOff) {
- for (let l = 0; l < word.letters.length; l++) {
- const index = ((word.row + l * word.incRow) * 15) + word.col + l * word.incCol;
- const tilePlaceholder = boardCells[index].getElementsByClassName("tile-placeholder")[0];
- const tile = tilePlaceholder.getElementsByClassName("tile")[0];
- if (onOff) {
+ if (onOff) {
+ for (let l = 0; l < word.letters.length; l++) {
+ const index = ((word.row + l * word.incRow) * 15) + word.col + l * word.incCol;
+ const tilePlaceholder = boardCells[index].getElementsByClassName("tile-placeholder")[0];
+ const tile = tilePlaceholder.getElementsByClassName("tile")[0];
+
tile.classList.add(value);
- } else {
- tile.classList.remove(value);
+ }
+ } else {
+ for (let index = 0; index < 15 * 15; index++) {
+ const tilePlaceholder = boardCells[index].getElementsByClassName("tile-placeholder")[0];
+ const tile = tilePlaceholder.getElementsByClassName("tile")[0];
+ if (typeof tile !== "undefined") {
+ tile.classList.remove(value);
+ }
}
}
}