Best Free Word Search Maker for Kids

Share this post

Try Our Tools

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
'); newWindow.document.close(); newWindow.focus(); setTimeout(() => { newWindow.print(); newWindow.close(); }, 1000); // Adjust timeout as needed for content to load before printing }function printAnswerKey() { const boardElement = document.getElementById('board').cloneNode(true);// Highlight the answer key boardElement.querySelectorAll('.cell').forEach(cell => cell.classList.remove('answer')); wordPositions.forEach(({ positions }) => { positions.forEach(({ row, col }) => { const cell = boardElement.querySelector(`.cell[data-row="${row}"][data-col="${col}"]`); cell.classList.add('answer'); }); });// Adjusting styles for printing const style = ``;const newWindow = window.open('', '', 'width=600,height=400'); newWindow.document.write('Print Answer Key' + style + ''); newWindow.document.write('

Word Search Answer Key

'); newWindow.document.write('
' + boardElement.outerHTML + '
'); newWindow.document.write('

My Baby Fitness

'); newWindow.document.write(''); newWindow.document.close(); newWindow.focus(); setTimeout(() => { newWindow.print(); newWindow.close(); }, 1000); // Adjust timeout as needed for content to load before printing }function toggleAnswerKey() { showAnswers = !showAnswers; const cells = document.querySelectorAll('.cell'); cells.forEach(cell => { const row = parseInt(cell.dataset.row); const col = parseInt(cell.dataset.col); if (showAnswers && isPartOfWord(row, col)) { cell.classList.add('answer'); } else { cell.classList.remove('answer'); } }); updateAnswerKeyButton(); }function isPartOfWord(row, col) { for (const word of words) { if (checkWordInDirection(word, row, col, 1, 0) || checkWordInDirection(word, row, col, 0, 1) || checkWordInDirection(word, row, col, 1, 1) || checkWordInDirection(word, row, col, -1, 1) || checkWordInDirection(word, row, col, -1, 0) || checkWordInDirection(word, row, col, 0, -1) || checkWordInDirection(word, row, col, -1, -1) || checkWordInDirection(word, row, col, 1, -1)) { return true; } } return false; }function checkWordInDirection(word, row, col, dx, dy) { for (let i = 0; i < word.length; i++) { const newRow = row + i * dy; const newCol = col + i * dx; if (newRow < 0 || newRow >= boardSize || newCol < 0 || newCol >= boardSize || board[newRow][newCol] !== word[i]) { return false; } } return true; }function updateAnswerKeyButton() { const button = document.querySelector('button[onclick="toggleAnswerKey()"]'); button.textContent = showAnswers ? 'Hide Answer Key' : 'Show Answer Key'; }function clearMessage() { const messageElement = document.getElementById('message'); messageElement.textContent = ''; }function displayMessage(message) { const messageElement = document.getElementById('message'); messageElement.textContent = message; }