UNPKG

311 BJavaScriptView Raw
1module['exports'] = function(colors) {
2 // RoY G BiV
3 var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
4 return function(letter, i, exploded) {
5 if (letter === ' ') {
6 return letter;
7 } else {
8 return colors[rainbowColors[i++ % rainbowColors.length]](letter);
9 }
10 };
11};
12