title: Why I have undefined on array on javascript
body: <p>I'm in the middle of a simple app, the idea is to randomly pick up without repeating the values ​​of an array.</p>
  <p>I managed to do it through a function but at the moment I started to go through it I got two undefined and I do not know why</p>
  <p>Sample of code :</p>
  <pre class="lang-js prettyprint-override"><code>var num = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  
  cont = 0;
  totalnum = num.length - 1;
  
  function next() {
    var indice = Math.floor(Math.random() * (cont &lt; totalnum ? ++cont : 0));
    var number = num[indice];
    document.getElementById(&quot;hola2&quot;).innerHTML = num.splice(indice, 1);
  }
  
  </code></pre>