Computer Choice Part 2 - Syntax Error


#1



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


It says there is an error in syntax. I've looked at my codes for quite long but couldn't figure out where I am wrong.


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random(); console.log(computerChoice); 
if (computerChoice <= 0.33) {
    computerChoice = "rock";
}
if else (computerChoice <= 0.66) {
    computerChoice = "paper";
}
else {
computerChoice = "scissors";
}


#2

This post was flagged by the community and is temporarily hidden.


#3

You started with "if else" instead of "else if".

instead of:
if else (computerChoice <= 0.66) {
computerChoice = "paper";

go with:
else if (computerChoice <= 0.66) {
computerChoice = "paper";


#4

Okay, I'm unable to see the mistake, and I'm pretty much in the same situation. Help pls?:cry:


#5

The below is Right:

var human=function(user,comp)
{
if(user==="rock" && comp==="scissors")
{
return "rock wins";
}
else if(user==="rock" && comp==="paper")
{
return "paper wins";
}
else if(user==="paper" && comp==="scissors")
{
return "scissors wins";
}
else if(user==="paper" && comp==="rock")
{
return "paper wins";
}
else if(user==="scissors" && comp==="rock")
{
return "rock wins";
}
else if(user==="scissors" && comp==="paper")
{
return "scissors wins";
}
};
human("paper","rock");