const listOfWords = ['angel', 'break', 'clear', 'knock', 'maybe'];
var userWord = readLine("Enter a 5 letter word: \n");
var randomItem = listOfWords[Math.floor(Math.random()*listOfWords.length)];
var newWord = userWord;
wordle();
function wordle(){
letterChecker()
for(var i = 0; i < 5; ++i){
var inputWord = readLine("Enter a new word: \n");
letterChecker();
}
}
function letterChecker() {
println(randomItem);
for(var i = 0; i < 5; i++){
if(newWord[i] === randomItem[i]) {
console.log(newWord[i] + " is green");
} else {
if(randomItem.includes(newWord[i])){
console.log(newWord[i] + " is yellow");
}
}
if(!randomItem.includes(newWord[i])){
console.log(newWord[i] + " is grey");
}
}
}
I understand that this is needs to be a more complicated dynamic variable within the for loop, however I don't understand how to make the letterChecker() function also then check up to five new instances of var inputWord. For context this is a wordle game and the outcome I get now is the program running only for one word regardless if a new word is declared within the readLine prompt.