Color Palette explainer

The aim of this puzzle: Create a red box by getting the color from an array.

Walkthrough of the solution: The beginning of the code creates an array called colors which just contains 4 strings: 'yellow', 'blue', 'red', and 'green'.

In JavaScript, the items in an array are numbered from beginning to end, starting at zero and going up just like regular counting. That means 'yellow' is the 0th item in the colors array and 'blue' is the 1st item in the colors array.

You’re able to choose a specific item from an array using the item’s index which is just a number.

Since you want a red box, you want to get the item at index 2 by using colors[2]. Now that you know how to access the 'red' item in the array, you want to use it to draw a redbox – simply put it inside of drawBox(). That means drawBox(colors[2]) will draw a redbox (as long as you don’t change the colors array).

Sample code solution:
(Tap below to reveal)

var colors = [

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

1 Like

in draw boxes practice, the DrawBoxes function contains blue arguments without quotes, while in the array there are quotes (string), why can this be different ?

How use keys for entering reserve word and inside value . I know the answer but unable to type the same. Explain the logic of key in of words and numbers.

ok so that oknb bgubugjbhg

So what!!!



um how to do this puzzle