Question: Please help with this exact code. I cannot get the value from the start function to enter the checkAnswer function. const words = [

Please help with this exact code. I cannot get the value from the start function to enter the checkAnswer function.
const words =["happy","lose","great","zainy","juice","point","grapes"];
function startGame(){
const hints=["a wonderful feeling","didn't win", "a feeling of mighty", "a crazy idea", "quenches your thirst","pencil tip","green and purple fruit"];
const arrayIndex =(Math.floor(Math.random()* words.length));
pickedWord=words[arrayIndex];
pickedHint=hints[arrayIndex];
document.getElementById("hintText").innerHTML=pickedHint;
document.getElementById("pickedWord").value=pickedWord;
return pickedWord;
}
let word = pickedWord;
function checkAnswer(word){
let correctAnswers=0;
let userGuess = document.getElementById("guessedWord").value;
console.log(userGuess);
if(userGuess ===word){
correctAnswers +=1;
}else{
alert("Please try again.");
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!