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’,
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???
Great question! When using array indexing you can only reference one number at a time.
colors) 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, colors, etc seperately.
I also noticed you referenced
drawBoxes() rather than
drawBox(). If your array holds the words
'black' you’ll want to use
drawBox(); if it holds
'b’ you’ll want to use
Hope this helps!
It looks like you’d use
'k' for black, thus:
drawBoxes('wkw kwk wkw')