# Gabonese Flag explainer

The aim of this puzzle: Create the Gabonese flag.
Walkthrough of the solution: The Gabonese flag has three horizontal stripes; the top stripe is green, the middle stripe is yellow and the bottom stripe is blue. To re-create the flag there needs to be 9 boxes — 3 boxes tall and 3 boxes wide. `drawBox(green)` will draw one green box (updating the color will change the color of the box). `newLine()` is used to make boxes appear below other boxes.
Sample code solution:
(Tap below to reveal)

``````drawBox(green);
drawBox(green);
drawBox(green);
newLine();
drawBox(yellow);
drawBox(yellow);
drawBox(yellow);
newLine()
drawBox(blue);
drawBox(blue);
drawBox(blue);
``````

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

16 Likes

I do not under stand

25 Likes

Whenever you press the green play button, all of the code inside of the “Your Code” section gets run, line by line from top to bottom. You need to create a list of commands that create a specific pattern when you read it from the first line to the last. In this puzzle, that pattern is the Gabonese Flag with has three horizontal stripes (green, yellow, and blue). You can see in the “Example Solution” section of the app that each stripe is three boxes wide.

To create a green stripe, you would need to draw three green boxes in a row which can be done by writing:

``````drawBox(green);
drawBox(green);
drawBox(green);
``````

To move the grasshopper down to the next row for your next stripe, you use `newLine()`. Then you can use the same pattern to create a different colored stripe, like yellow.

After you have a green and yellow stripe, you can move the grasshopper to a `newLine()` again and create the last row of three blue boxes.

Hope this is helpful. If there are any parts that are unclear, feel free to ask me about them!

–Frankie

10 Likes

So the drawbox meathead draws a box. To tell the script (drawbox) you say the color that the code wants you to do.

7 Likes

How does the drawBox() function know to draw horizontal long box as with Gabonese flag or a small box as with French Flag

3 Likes

Hey there,

All of the boxes are the same size. By calling the function 3 times with the same color, the 3 boxes look like a stripe.

–Ben

11 Likes

are you from welch Newnan GA

3 Likes

I don’t understand neither so they put a hint button so tap it and I thinks so they will so never give up cater:wink:

5 Likes

no sorry l’am from africa

4 Likes

chrome 78 beta - numerous errors prevent proper function for buttons. unable to complete lesson due to errors… plz fix in meantime i have to use older browser versions or FFox.

1 Like

Hey there, those warnings are unrelated. They are warning that a future version of Chrome is going to make some slight changes to how cookies work on websites.

Can you describe the issue you are having?

Thanks,
Ben

1 Like

– resolved – was my mistake

2 Likes

Duh with cheese and stuff, me too

2 Likes

Hi, beginning to understand at the very early stages of coding could you enlighten me on some other aspects that may be needed to start to be able to build my own and thank you so much you’re very self-explanatory and it’s clear and concise appreciate that Dixie Nunley/ Longoria

1 Like

I tried to use drawBox() function in vs code and other online compilers but it is not working. So, how can I use this function?

1 Like

Hey there, `drawBox()` is a custom function that we created just for use within Grasshopper. You can read more about Grasshopper’s custom functions here.

Hope this helps!
Ben

1 Like

hey there i am new and i want to meet everyone but sometimes i do some work here from my lyberary teacher

2 Likes

hey how do you code the 2 flag.

3 Likes

you just follow instructions and you’ll be fine.

2 Likes

Hi, i am new to coding. is this the right place for me to learn coding?

4 Likes