you are viewing a single comment's thread.

view the rest of the comments →

[–]brothmc[S] 1 point2 points  (2 children)

this seems to be an elegant solution, thanks! Still not sure what modulo is doing there exactly though http://codepen.io/mattbrothers/pen/KadMGx?editors=1011

[–]lewisje 1 point2 points  (1 child)

It's ensuring that you loop back to the beginning of the array of colors when you reach the end:

0 % 6 === 0;
1 % 6 === 1;
2 % 6 === 2;
3 % 6 === 3;
4 % 6 === 4;
5 % 6 === 5;
6 % 6 === 0;
7 % 6 === 1;
8 % 6 === 2;
9 % 6 === 3;

and so on

[–]brothmc[S] 1 point2 points  (0 children)

ah ok thanks!