What is the code for 4. Computer Choice Part 2


#1

Please paste code i am stuck


#2

@august_kirchoff you have to try writing some code on your own and then why you get errors you cant decipher that's when you come here


#3

here is a question, what are the symbols for in between 0.34 and 0.66? i only know =<, =>, ===, =, and >, and <.


#4

There is no symbol for in between, what you could do is chaining two statements

0.34 < x and 0.66 > x

where the JS operator for and is &&. But the easier way is too think if you really need all of the boundary conditions. e.g. if your first range goes from 0 to 0.33 you already made sure that x must be bigger to even get to this condition.


#5

here is my code; it says "syntaxerror: missing ) after condition" what did i do wrong here is code:
var userChoice = prompt("Rock, Paper, Scissors!");
console.log( computerChoice = Math.random() )
if( computerChoice > 0 and < 0.33) {
computerChoice === "Rock"
} else if(computerChoice > 0.34 and < 0.66 ) {
computerChoice === "Paper"
} else {
computerChoice === "Scissors"
}


#6

As said in javaScript the and is written by &&. Also < is a binary operator meaning that it needs to values to work on but in your case it sees 0.33 to the right and and to the left so to make this work you at least need to add another computerChoice. The interpreter doesn't understand context that well. Also think about if computerChoice > 0 s really necessary if Math.random() always generates numbers that are 0 or bigger?


#7

Thanks haxor u rock man