Help with if then statements and console .log


#1

Computer Choice Part 2

It says " TypeError : console.log is not a function

var userChoice = prompt("Do you pick rock, paper, or scissors?");
var computerChoice=Math.random();
console.log(computerChoice);
if (computerChoice >= 0 && computerChoice <= 0.33){

    console.log("Rock");
    

}else if (computerChoice >= 0.34 && computerChoice <= 0.66){
        
            console.log("Paper");
        
    
 }else{
    
         console.log("Scissors");
     
 }


#2

you have to assign values to computerChoice in your if else statement
like

if ( computerChoice <= 0.33){
 computerChoice="Rock"
else if(condition){
 // statement
}
else{
 //statement  
}

instead of this
if (computerChoice >= 0 && computerChoice <= 0.33){

you can write
if ( computerChoice <= 0.33){

same for the next

remove console.log in your if else statement and refresh your browser


#3

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