<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
```
var choiceData=[“rock”,“paper”,“scissors”];
var userChoice = prompt(“Do you choose rock, paper or scissors?”);{
while (userChoice===null||userChoice!=choiceData.find(n=>n==userChoice)){
alert(“Error! Please try again!”);
var userChoice = prompt(“Do you choose rock, paper or scissors?”);
}
}
var computerChoice = Math.random();{
if (computerChoice < 0.34) {
computerChoice = “rock”;
}else if(computerChoice <= 0.67) {
computerChoice = “paper”;
}else {
computerChoice = “scissors”;
}
}
var response=("You choose “+userChoice+” and Computer choose “+computerChoice+”. ");
function compare(choice1,choice2){
if (choice1===“rock”) {
if (choice2===“scissors”) alert("Congratulations! "+response+“Your rocks wins!”);
else alert(“Oh no! “+response+” Computer’s paper wins!”);
}else if (choice1===“paper”){
if (choice2===“rock”) alert("Congratulations! "+response+“Your paper wins!”);
else alert(“Oh no! “+response+” Computer’s scissors wins!”);
}else {
if (choice2===“paper”) alert("Congratulations! "+response+“Your scissors wins!”);
else alert("Oh no! "+response+“Computer’s rock wins!”);
}
}
while(userChoice===computerChoice){alert(response+“Draw! Try again!”); //Where should I put this…
var userChoice = prompt(“Do you choose rock, paper or scissors?”);
}
compare(userChoice,computerChoice);
The general wherewithal of this question exceeds the current level of code awareness. That brings into question the genuineness of the question. We cannot comment on copied code. Explain or abandon, at this point.
var choiceData=[“rock”||“paper”||“scissors”];
var userChoice = prompt(“Do you choose rock, paper or scissors?”);{
while (userChoice===null||userChoice!=choiceData){
alert(“Error! Please try again!”);
var userChoice = prompt(“Do you choose rock, paper or scissors?”);
}
}
I purposely keep the loop for cancel so that nobody can escape if they don’t try to answer. The main problem here is not about null and choiceData loop, it’s about:
while(userChoice===computerChoice){alert(response+“Draw! Try again!”); //Where should I put this…
var userChoice = prompt(“Do you choose rock, paper or scissors?”);
}
I want to create loop that alert the user to try again and prompt again if the userChoice===computerChoice. But I am not sure where should I put this block and it keep continue to create infinite loop. Help me please, thank you.
It is never a good practice to disable a user’s ability to exit at any time. Lock them in a loop goes against the intent of Cancel/Esc.
What is evident here is that the OP has still not mastered some of the necessary skills needed to take this project to the next level. I would recommend completing the entire JS track then come back to this project when you will be better equipped.