Results in a tie


#1

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/1?curriculum_id=506324b3a7dffd00020bf661#

so my code comes back as a tie like its supposed to, but codeacademy is telling me that its not coming back with results are a tie when it is. can anyone help me to undestand why?


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";
    }
}
console.log(compare(userChoice, computerChoice));


#2

Check this text string against the one in the instructions. Is it the same?


#3

Hi methodcoder you need to remove this semicolon here

} else {
computerChoice = "scissors";
};<---------here

and place a semicolon here

if(choice1 === choice2) {
    return "The result is A tie";
}

}<------ here


#4

Hi there!! I got the same problem,looks like i am doing well but the return is mistake!

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!";
}};


#5

Check your text string against the one in the exercise and you're sure to crack the case.


#6

I too experienced the same!!
Please type the commands exactly the same way mentioned in the "Instructions"
Even though your codes are the same(and might be correct) it still reports error due to mismatch in text!
In your case try changing return " The result is A tie"; ** to **return "The result is a tie!".

PS: At times its best to simply copy the text from the "Instructions" box!


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.