title: Using Loops to Create a Word Scrambler
body: <p>Trying to create a word scrambler which takes text from a text box, scrambles the letters, and repeats them in a different text box.  Code must use a loop to distribute the text across an array of letters. Once I reach the Math.floor Object, I'm confused as to how to proceed.</p>
  
  <p>Relevant Code:  </p>
  
  <pre class="lang-html prettyprint-override"><code>    &lt;script type="text/javascript"&gt;
  
      var word = document.getElementById("input").value;
      var wordLength = word.length;
      var scrambled = "";
  
      for (var i = 0; i &lt; wordlength; i++) {
          var charIndex = Math.floor(Math.random() * word.length);
          scrambled += word.charAt(charIndex);
          word = word.substr(0, charIndex) + word.substr(charIndex + 1);
      }
  
      document.getElementById("output").value = scrambled;
  
      }
  
      &lt;/script&gt;
  
      &lt;head&gt;
      &lt;body&gt;
      &lt;form&gt;  
      &lt;input type="text" name="input" id="input" value="" maxlength="10"&gt; &lt;input type="text" name="output" id="output" value="" disabled="true"&gt;&lt;br/&gt;
      &lt;input type="button" name="generate" value="Generate" onClick="Scramble(this.form)"&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>