Data structures lesson
Ideas
Word Guessing Game
Guess the word:
Enter a letter:
Number of guesses remaining:
for (let i = 0; i < word.length; i++) {
if (word[i] === letter) {
wordLetters[i] = letter;
foundLetter = true;
}
}
- This is a loop that iterates over the letters in the word and checks to see if the guessed word matches any of the letters in the actual word
- afer iterating, if the word matches it will mark the letter as found adn the user will get instant feedback and see if the word was chosen
const words = ['apple', 'banana', 'cherry', 'orange', 'pear'];
- here is the list of possible words
- Each of the words are stored in the list that is created in javascript