Illustrated 8-ball explainer

The aim of this puzzle: Draw a pattern of boxes if the magic-8 ball answer is ‘yes’.
Walkthrough of the solution: The answers to the magic-8 ball are stored in a variable called thing. To start with an if statement draws a pattern of boxes if the variable thing is no. To complete this card you’ll need to type out a copy that if statement; updating it so that it’s checking for 'yes' rather than 'no'. And then create your own pattern of boxes using the string str key.
Sample code solution:
(Tap below to reveal)

var thing = pickRandom([
  'yes', 
  'no'
]); 
print(thing);
if (thing === 'no') {
  drawBoxes('rwr wrw rwr')
}
if (thing === 'yes') {
  drawBoxes('wwg gwg wgw')
}

JavaScript Concepts: Data Structures (arrays), Code Block (if statement), Calling Functions, Identifiers, Conditionals (if statement), Binary Expression (===)
Grasshopper Concepts: pickRandom(), drawBoxes(), print()

1 Like