Question: Please help I can't figure out how to repeat the program for 5 guesses and then display the status after running the start game and

Please help I can't figure out how to repeat the program for 5 guesses and then display the status after running the start game and check answer codes.
Please tell me how to adjust this code.
const words =["happy","lose","great","zainy","juice","point","grapes"];
let pickedWord="";
let guesses =0;
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];
const pickedHint=hints[arrayIndex];
document.getElementById("hintText").innerHTML = pickedHint;
document.getElementById("pickedWord").value = pickedWord;
}
function checkAnswer(){
let correctAnswers=0;
let userGuess = document.getElementById("guessedWord").value;
console.log(userGuess);
if(userGuess ===pickedWord){
correctAnswers +=1;
alert("You are right. "+ correctAnswers + "number of right answers.");
}else{
alert("Please try again.");
}
let status="";
switch (correctAnswers){
case 5:
status="You are a pro";
break;
case 3:
status="You are becoming experienced";
break;
default:
status="You need more work.Try again";
break;
}
document.getElementById("gameResults").innerHTML = status;
}

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!