Code playground issue

I am trying to experiment off of the checkerboard lesson in code playground to see if I can simplify the code and garner the same results using

Var colors = [ ‘white’,
‘black’ ]
Drawboxes(colors[010 101 010])

To see if it would create a checkerboard using less code, however I cannot get brackets to insert after color in my drawboxes ()

Also would that string of code work???

Hi @Mindy_cameron_Sudden,

Great question! When using array indexing you can only reference one number at a time. colors[010101010]) would ignore the first 0 and look for the 10,101,010th item in the array (that would be a very big array).

Instead, you’ll want to use colors[1], colors[0], etc seperately.

I also noticed you referenced drawBoxes() rather than drawBox(). If your array holds the words 'white' or 'black' you’ll want to use drawBox(); if it holds 'w' or 'b’ you’ll want to use drawBoxes().

Hope this helps!
H :slight_smile:

1 Like

It looks like you’d use 'k' for black, thus:

drawBoxes('wkw kwk wkw')