Help on js


#1

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

Please could someone enlighten me?


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.33 && computerChoice <= 0.66){
    computerChoice ="paper";
}
else(computerChoice >= 0.67 && computerChoice <= 1){
    computerChoice ="scissors";
}


#2

else(computerChoice >= 0.67 && computerChoice <= 1){
    computerChoice ="scissors";
}

else doesn't allow to have a condition.

also you dont need that condition.

The random() method returns a random number from 0 (inclusive) up to but not including 1 (exclusive).


#3

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