Mass Transit explainer

The aim of this puzzle: Create an if statement that runs a block of code only if a certain condition is true.

Walkthrough of the solution: In this puzzle, you’ll create an if statement. An if statement works like this:

if (thisIsTrue) {
  runThisCode
}

In this puzzle, the transport variable uses pickRandom() to choose between 'train' and 'bus'. An if statement prints a message if transport is equal to (===) 'bus'.

To complete the puzzle, use print() in the code block {} of the 2nd if statement to print a message if transport is equal to (===) 'train'.

Sample code solution:

(Tap below to reveal)

var transport = pickRandom(['train', 'bus']);
print(transport);

if (transport === 'bus') {
  print('Taking the bus.');
}

if (transport === 'train') {
  print('Taking the train.');
}

JavaScript Concepts: Binary Expression (===), Calling Functions, Conditionals (if statement), Data Structures (Arrays), Identifiers, Variable Declaration

Grasshopper Concepts: pickRandom(), print()

1 Like

What is that explainer @Grasshopper_Ben? I mean, why has that been created?

1 Like

how to do this puzzle it is so hard for me so what should I do guys please

what should I do please tell me

please sgsggs63gvdtfrgyrgetygdhyurgduydujebdgjyuxdhnydghjundbyuh.com