title: displaying characters with colors
body: <p>I'm trying to create a Javascript function that randomly assigns the characters in a string to a set of colors I have chosen. I'm not quite sure how to select a character in the string and assign it a color</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    &lt;script&gt;
          function Rainbow(x,chosencolor) {
              var mystring = String(x);                                              @* convert to string*@
              var Stringlength = mystring.lenth;                                     @* length fo string *@
              var rainbowstring = new Array(Stringlength);                           @* create array of appropriate size*@
              var counter = 0;
  
              while (counter &lt; Stringlength) {
                  var randomnumber = Math.floor(Math.random() * 10);                     @* random number generator --&gt; 11 means 0-10 *@         
  
                    switch (randomnumber) {
                      case 0:
  
                          break;
                      case 1:
  
                          break;
                      case 2:
  
                          break;
                      case 3:
  
                          break;
                      case 4:
  
                          break;
                      case 5:
  
                          break;
                      case 6:
  
                          break;
                      case 7:
  
                          break;
                      case 8:
  
                          break;
                      case 9:
  
                          break;
                  }
                  rainbowstring[counter] = chosencolor;                              @* assign color *@
                  counter++;                                                         @* increment *@
              }
       }
  
          @* need something that generates colors *@
          @* assigns colors to text *@
  
      &lt;/script&gt;
  </code></pre>