Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 这个程序可以运行,但代码学院不能';我不认为这是正确的_Javascript - Fatal编程技术网

Javascript 这个程序可以运行,但代码学院不能';我不认为这是正确的

Javascript 这个程序可以运行,但代码学院不能';我不认为这是正确的,javascript,Javascript,这是我的代码: 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 { compute

这是我的代码:

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(choice1, choice2){
if (choice1 === choice2) {
    return "The result is a tie!";
}

else if (choice1 === "rock") {

    if(choice2 === "scissors") {
        return "Rock smashes the fuck out of those scissors!";
    }
    else {
        return "Oh shit, that rock was not prepared for full coverage OF PAPER ";
    }
}

else if (choice1 === "paper") {

    if (choice2 === "rock"){
        return "Oh damn, that paper just covered the shit out of that rock!";
    }
    else {
        return "Those scissors cut that weak paper shit into pieces!";
    }
}

else if (choice1 === "scissors") {

    if (choice2 === "rock"){
        return "Wow! That rock smashed those scissors so hard into the ground that their grandparents felt it. And they're dead!";
    }
    else {
        return "That wimpy-ass paper was sliced into ribbons...Well, you know, if the paper was made of that ribbon material. BUT IT'S NOT.";
    }
}
} 
compare(computerChoice, userChoice);    
var userChoice=prompt(“您选择石头、布还是剪刀?”);
var computerChoice=Math.random();

如果(computerChoice您需要像CodeAcademy希望您做的那样做所有事情。使用相同的变量名称、相同的代码结构等。

控制台和计算机都产生相同的结果,因此我不知道您要做什么才能得到
未定义的
。CodeAcademy如何检查您的答案?您需要返回与它们匹配的字符串吗输出?是否有亵渎检查?