Rock exercise part 2


#1


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

Oops, try again. There was a problem with your syntax.

expect correct

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="paper";
}

    else(computerChoice<=1) {
    computerChoice="scissors";
}
console.log(computerchoice)


#2

@lodum,
An ELSE statement does not take a condition

following the Instructions the conditions would be:

  1. If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".
    ( 0 <= computerChoice && computerChoice <= 0.33) which we capture at the IF using
    ( computerChoice <= 0.33)

  2. If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper".
    ( 0.33 < computerChoice && computerChoice < 0.67) which we capture at the ELSE IF as
    ( computerChoice < 0.67 )

  3. If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
    ( 0.67 <= computerChoice && computerChoice < 1) , you reached the ELSE level
    you can asume that computerChoice is greater equal to 0.67,
    the ELSE does NOT take a condition, just write your code.


#3

Forgive my ignorance, what does "&&" indicate?


#4

@lodum,
The && is a so-called AND-logical-operator
Read in
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators


#5

thanks for the help, I appreciate it.


#6

2 posts were split to a new topic: What is wrong in my code plz help