Step four: Good afternoon codemen. Please tell me what is wrong with my code. Thankyou


#1

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

Oops, try again.
Your code doesn't look quite right. Check the Hint if you need help!


Replace this line with your code. 

var varName = "userChoice"
var computerChoice = Math.random()
if (comuterChoice <= 0.34){
computerChoice ="rock";
}
else if (computerChoice <= 0.67) {
computerChoice ="paper";
}
else {
computerChoice ="scissors";


#2

else if (computerChoice <= 0.66) {
computerChoice ="paper";
}

not
else if (computerChoice <= 0.67) {
computerChoice ="paper";
}


#3

check your spelling here

if (comuterChoice <= 0.34) // computer

and close else statement

also read the instructions

If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".


#4

Oh, what a mistake! Thank you and good day.


#5

I have stuck again in step 6. Kindly assist. This is my code:

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie!";
}
else if(choice1==="rock") {
if(choice2 === "scissors") {
return "rock wins";
}
else {
return "paper wins";
}

}

and the url is:

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


#6

you should create a new post so everyone can help you .you'll get faster answer :slight_smile:

however, close the function after closing else if statement.
just add }


#7

I have created a new post. But by putting a } symbol its also not working. Where else could the problem be. Thanks.


#8

you have to call the function.without calling it'll not work. post your updated code.

and check it how function works

https://discuss.codecademy.com/t/i-do-not-understand-how-to-call-a-function-what-am-i-doing-wrong/37701/7?u=rcodeman


#9

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