# Lesson 4 Part 2

#1

how is AI unexpected and why is it giving me an error for expecting ) to end an if statement i thought i out a ) to end it, did i not?

#2

Not even close to what the instructions ask. Start over, carefully following the instructions, to the letter.

Hint: Ignore the business about `between` that is throwing so many people off. Just start from the lowest interval and work upward.

``````// pseudo-code

if x < 1/3

else if x < 2/3

else``````

#3

its it exactly as far as i can see only difference is instead of using computerChoice i used AI which shouldn't change the outcome. i only changed it because it was giving me that exact error so to make sure i wasn't typing computerChoice wrong anywhere i changed it to something smaller and more efficient. i have read over the instructions and dont see what im doing wrong.

#4

You are right in testing, though I still suggest working with the exact values given, and solve as necessary with all the expected elements present.

The syntax error is the interpreter, not the lesson checker so that means you have an error that is preventing the code from being parsed. Paste your raw text code into a reply so we can see and test it, ourselves. The picture above tells us very little.

#5

var userChoice =prompt("Do you choose rock, paper, or Scissors?")
var AI=Math.random()
console.log(AI)
if (AI >.33) {
console.log("rock");
}
else if(AI<.34 AI<.66){
console.log("paper");
}
else{
console.log("scissors");
}

#6

one thing im not sure about is doing else if AI is between .34 and .66 then AI picked "paper". did i do that correctly in the code above?

#7

Changing direction of comparisons in an if statement really confuses things. Check the example above and keep the direction constant.

This is invalid code:

Consider:

1. computerChoice is less than 1
2. computerChoice is a positive float
3. the interval between 0 and 1 is to be divided into three intervals

``````    0..0.33;  0.33..0.66; 0.66..1
rock      paper       scissors``````

Testing the lowest interval first, elliminates it from the test sample. We have no need for a lower bound in the `else if`.

``````if x < 0.34

else if x < 0.67

else``````

#8

well that worked but the reason i didnt do that was because <.66 is include<.33 which would be 2 answers but now thinking about the process the computer takes to find the answer that wouldn't make since. THANKS FOR THE HELP!

#9

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