Checkerboard Helper explainer

The aim of this puzzle: Use drawBoxes() and newLine() function calls to create a checkerboard.
Walkthrough of the solution: Instead of drawing the first row of boxes using three drawBox() function calls:

drawBox(white);
drawBox(black);
drawBox(white);

we can simplify that by using the drawBoxes function just once. drawBoxes() uses a string and turns each letter of the string into a box. A string is one of the basic data types in programming, and is used to store text. It looks like a group of letters and/or numbers that always have quote marks around it: 'this is a string'.

To make white and black boxes, you use the letters 'w' and 'k'. The first row of the checkerboard is created with one function call: drawBoxes('kwk'); Then a newLine() is used to move the grasshopper to the next row. The starter code draws 2 of the 3 rows. Add another newLine() to move the grasshopper to the third row. Finally, add one more drawBox() function call to create a row of black-white-black boxes. To do that you use the command drawBoxes('kwk');
Sample code solution:
(Tap below to reveal)

drawBoxes('kwk');
newLine();
drawBoxes('wkw');
newLine();
drawBoxes('kwk');

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

What is for a black box e or k

1 Like

Why we use k for black instead ‘black’ word

1 Like

@Somnath_Jadhav @kondeti_praneet

Hey there, you can see all the colors here.

12345678901234567890123456789088

hi
i am newScreenshot 2020-12-01 at 8.52.40 AM

hi i am new :grin: :sweat_smile: :innocent: :innocent: :innocent: :laughing:

1 Like
 hbjnjbhvvmc [quote="grasshopperexplainer, post:1, topic:6628, full:true"]

The aim of this puzzle: Use drawBoxes() and newLine() function calls to create a checkerboard.
Walkthrough of the solution: Instead of drawing the first row of boxes using three drawBox() function calls:

drawBox(white);
drawBox(black);
drawBox(white);

we can simplify that by using the drawBoxes function just once. drawBoxes() uses a string and turns each letter of the string into a box. A string is one of the basic data types in programming, and is used to store text. It looks like a group of letters and/or numbers that always have quote marks around it: 'this is a string'.

To make white and black boxes, you use the letters 'w' and 'k'. The first row of the checkerboard is created with one function call: drawBoxes('kwk'); Then a newLine() is used to move the grasshopper to the next row. The starter code draws 2 of the 3 rows. Add another newLine() to move the grasshopper to the third row. Finally, add one more drawBox() function call to create a row of black-white-black boxes. To do that you use the command drawBoxes('kwk');
Sample code solution:
(Tap below to reveal)

drawBoxes('kwk');
newLine();
drawBoxes('wkw');
newLine();
drawBoxes('kwk');

JavaScript Concepts: Calling Functions, Identifiers
Grasshopper Concepts: drawBoxes(), newLine()
[/quote]
bbn vbcxghcxvgbhnbvhhnbhgbvghbtyh
m

mbvcvcdfyfdhbgyjxzhstftd