Variable not changing to string


#1


computer choice part 2

my computerChoice variable is not changing to the string associated with the random number


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();

console.log(computerChoice);

if(computerChoice < 0.33){
    computerChoice === 'rock';}
    
    else if(computerChoice < 0.66){
        computerChoice === "scissors";}
        
        else{
            computerChoice === 'paper';}

console.log(computerChoice);


#2

Can you include the link to this lesson, or the name of it?


#3

#4

I should've seen your problem earlier.

You are comparing if computerChoice is equal to rock scissors and paper rather than setting it equal to them after your if, else if, and else statements. Also, Why are your else if and else statements indented? They should be in line with your if statement.


#5

Hi Thanks for the help. I was using strictly equals rather than the assignment operator


#6

Yeah, no problem! Did you get passed the lesson?


#7

yea .... all good. Thanks!!


#8

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