Shorter Rainbow Explainer


The aim of this puzzle: Use a For…of loop to draw a rainbow two columns wide, with a different color on each row.
Walkthrough of solution: A For…of loop is set up to loop through an array of colors. On each iteration (loop), the variable x will refer to the current element in the array. For example, on the 1st iteration, x has the value 'red', so the code in the code block:


will draw 1 red box before jumping to a new line.

To complete the puzzle, add a 2nd drawBox(x) to the For…of loop to draw a rainbow 2 columns wide.

Sample code solution:
(Tap below to reveal)

for (var x of [
]) {

JavaScript Concepts: Loops, Arrays, Blocks (for loop), Identifiers, Variable Declaration, Calling Functions
Grasshopper Concepts: drawBox(), newLine()

listed #2