Flag Switcher explainer


#1

The aim of this puzzle: Reverse the order of the flag’s colors by swapping the variables used in the drawBox() function.
Walkthrough of the solution: In this puzzle, you will use variables to store the names of colors, and then use those variables for the drawBox() function.

The variable g holds the string 'green', while w holds the string 'white', and o contains the string 'orange'. This means that drawBox(o) is the same as drawBox('orange').

To turn the Irish Flag into the Ivory Coast flag, change the drawBox() function calls to use the correct variables, by switching o and g. No new lines of code will need to be added.
Sample code solution:
(Tap below to reveal)

var g = 'green';
var w = 'white';
var o = 'orange';

drawBox(o);
drawBox(w);
drawBox(g);
newLine(); 
drawBox(o);
drawBox(w);
drawBox(g);

JavaScript Concepts: Variable Declaration, Calling Functions, Identifiers
Grasshopper Concepts: drawBox(), newLine()