title: Scrambling a word in javascript
body: <p>I want to make a system which scrambles word, example: <code>Hello</code> -&gt; <code>llHoe</code>.
  The problem is that it sometimes shows <code>undefined</code> in the console and I can't find any problems.</p>
  <p>This is the code I've made:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function GenerateWord() {
      var Words = ["Hello", "Bye", "Tree"]
      var RandomNumber = Math.floor((Math.random() * Words.length));
      var CorrectAwnserString = Words[RandomNumber];
      var CorrectAwnser = CorrectAwnserString.split("");
      var WordToOrder = "";
  
      for(i = CorrectAwnser.length; i &gt; 0;) {
          let RandomLetter = Math.floor((Math.random() * i));
          WordToOrder = WordToOrder + CorrectAwnser[RandomLetter];
          console.log(WordToOrder)
          CorrectAwnser.splice(RandomLetter);
          console.log(CorrectAwnser)
          i = i - 1;
      }
  
      document.getElementById("OriginalWord").innerHTML = CorrectAwnserString;
      document.getElementById("MessedWord").innerHTML = WordToOrder;
  }
  GenerateWord();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="OriginalWord"&gt;&lt;/div&gt;
  &lt;div id="MessedWord"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>