Rock Paper Scissors


#1

What is wrong with my code?

var computerChoice = function getRandom() {
  return Math.random();
}

if (computerChoice <= 0.33){
    var cc = "rock";
}
else if (computerChoice <= 0.75 && computerChoice > 0.33) { 
    var cc = "paper";
}
else if (computerChoice > 0.75) { 
    var cc = "scissors";
}

//Addressing what the user inputs 
var uc = prompt("What is your choice? (Enter 'rock' , 'paper', or 'scissors' ");

//Tie 
if (cc === uc ){ 
    console.log ("Tie");
}
else if (cc === "rock" && uc === "paper" && cc != uc) {
    console.log("You win!");
}
else if (cc === "rock" && uc === "scissors" && cc != uc) { 
    console.log("Computer wins :(");
}
else if (cc === "paper" && uc === "rock" && cc != uc){ 
    console.log("Computer wins :(");
}
else if (cc === "paper" && uc === "scissors" && cc != uc) { 
    console.log("You win!");
}
else if (cc === "scissors" && uc === "rock" && cc != uc) { 
    console.log("You win!");
}
else if (cc === "scissors" && uc === "paper" && cc != uc) { 
    console.log("Computer wins:(");
}

#2

Please post the error you are getting. Thanks! :smile: Please give the exercise link. Thank you! :smile:


#3

Just realized I did the exercise ahead and there was a module on it. The error was that no output was being given.