Он говорит, что ожидается объект line one char 1, но нет ни одной ошибки, что мне делать?
function userChoice = prompt("Do you want to choose rock, paper or scissors?"); if (userChoice !== "rock" || userChoice !== "paper" || userChoice !== "scissors") { console.log("Invalid choice. Please choose rock, paper or scissors.") prompt("Do you want to choose rock, paper or scissors?"); } console.log("Player: " + userChoice); var computerChoice = Math.random(); if (computerChoice < 0.34) { computerChoice = "rock"; } else if (computerChoice <= 0.67){ computerChoice = "paper"; } else { computerChoice = "scissors"; } console.log("Computer: " + computerChoice); function compare(choice1, choice2){ if (choice1 === choice2) { console.log("The result is a tie"); } else if (choice1 === "rock") { if (choice2 === "scissors") { console.log("rock wins!"); } else { console.log("paper wins!"); } } else if (choice1 === "paper") { if (choice2 === "scissors") { console.log("scissors win!"); } else { console.log("paper wins!"); } } }; compare(userChoice, computerChoice);
Что я уже пробовал:
var userChoice = prompt("Do you want to choose rock, paper or scissors?"); if (userChoice !== "rock" || userChoice !== "paper" || userChoice !== "scissors") { console.log("Invalid choice. Please choose rock, paper or scissors.") prompt("Do you want to choose rock, paper or scissors?"); } console.log("Player: " + userChoice); var computerChoice = Math.random(); if (computerChoice < 0.34) { computerChoice = "rock"; } else if (computerChoice <= 0.67){ computerChoice = "paper"; } else { computerChoice = "scissors"; } console.log("Computer: " + computerChoice); function compare(choice1, choice2){ if (choice1 === choice2) { console.log("The result is a tie"); } else if (choice1 === "rock") { if (choice2 === "scissors") { console.log("rock wins!"); } else { console.log("paper wins!"); } } else if (choice1 === "paper") { if (choice2 === "scissors") { console.log("scissors win!"); } else { console.log("paper wins!"); } } }; compare(userChoice, computerChoice);