3
當我運行我的程序,我得到預期的輸出,但我也收到錯誤:結果我的代碼
"Your function doesn't return the value"
這裏是我的代碼:
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";
}
//console.log("Computer: " + computerChoice);
var compare = function(userChoice,computerChoice){
if (userChoice === computerChoice) {
return "The result is a tie";
}
else{
return "False" ;
}
};
var pp = compare(userChoice,computerChoice);
console.log(pp);
你是什麼意思? –
這段代碼寫的是什麼?什麼是預期的輸出.. ?? –
如果(computerChoice <= 0.67)導致我認爲你想說別的if(computerChoice> = 0.34 && computerChoice <= 0.67)......你可能需要改變其他的邏輯...? –