Why is <0.66 sufficient?


#1

var userChoice = prompt("Do you choose rock, paper or scissors?")

var computerChoice = Math.random()
console.log(computerChoice)

if (computerChoice <= 0.33 ){
console.log("Rock")
}
else if (computerChoice <= 0.66){
console.log("paper")

}
else{
console.log("scissors")
}


The program above works but is not relevant to the question. it is asking the random number between 0.34 and 0.66 to output 'paper' , for example. But takes condition <= 0.66 , which covers 0 to 0.66, which would actually be wrong.


My computerChoice output does not correlate to Math.random?
#2

If it is not related to a question than please open a new topic. I hope you like the title, if not feel free to change it.

On your question think about under which conditions the else if case is even evaluated maybe.
Also you're meant to change the value of computerChoice not to console.log something.