Greater or Lesser explainer

The aim of this puzzle: Update the test (the part inside the parentheses) of the second if statement to check if x is greater than 8 OR if y is greater than 8.
Walkthrough of the solution: There are several new concepts in this puzzle!

The first new concept is the introduction of two new comparison operators, < (less than) and > (greater than). They are used to compare two different numbers.

The second new concept is the “or” logical operator ||. “Or” is similar to the “and” operator &&, and is used to check if 2 separate conditions are true. However, only 1 condition needs to be true for the || operator to return true. For example:

if (time > 10 || tiredness === 'yes') {
  print('You should go to bed');

The if statement uses || to check if time is greater than 10 and if tiredness is equal to 'yes'. Because this is using the || operator and not &&, only one of these conditions needs to be true.

To complete the puzzle, update the numbers in the second if statement to check if x is greater than 8 OR if y is greater than 8.

Example solution:
(Tap below to reveal)

print('x is ' + x);
print('y is ' + y);
if (x < 9 && y < 9) {
    print('x and y are less than 9');
if (x > 8 || y > 8) {
    print('x or y, or both, are greater than 8');

JavaScript Concepts: Logical Operators, Comparison Operators, If Statement, Calling Functions, Identifiers
Grasshopper Concepts: print()

Additional Code (hidden code that runs before the puzzle’s code):

var x = pickRandom(13);
var y = pickRandom(13);

This lesson has me confused. I understand what they’re asking me, but I don’t know what to do. (If that makes sense)


Hey there,

This puzzle shows how the && (and) and || (or) operators are used. When the puzzle loads, the 2nd if statement has if (x > 1 || y > 1). Change the test inside the parentheses to instead check if x > 8 || y > 8.

Hope this helps!

only 0 to 13 and why there is no chance to provide x and y values.

1 Like

What should i apdate in the second if statement? And i update it with what? Numbers or words,because i see the statement is already updated!!!