title: How can I slice a number into smaller digits to fit my array
body: <p>I am making a counter which will show the sum of dice rolled. At the moment if i go over 9 it turns into zero. I need to slice up the number of <em>zeroValue</em> into one digit long sections. so 123 becomes 1 <strike>23</strike>, <strike>1</strike> 2 <strike>3</strike>,  <strike>12</strike> 3. So that it fits into my array. I tried something like this:</p>
  
  <pre><code>function diceResult(){
  
  var whichNumber = 123; // this number will change, depending on sum of dice rolled
  
  var getTextNumber = new Array (9)
  getTextNumber[0] = "zero";
  getTextNumber[1] = "one";
  getTextNumber[2] = "two";
  getTextNumber[3] = "three";
  getTextNumber[4] = "four";
  getTextNumber[5] = "five";
  getTextNumber[6] = "six";
  getTextNumber[7] = "seven";
  getTextNumber[8] = "eight";
  getTextNumber[9] = "nine";
  
  var zeroValue = getTextNumber[whichNumber];
  
  var getZero = diceToolbarCounterWrapper.getElementsByTagName("li");
  
      getZero[2].className = zeroValue.slice(2, -0; /* &lt;------ I tried this */
      getZero[1].className = zeroValue.slice(1, -1);
      getZero[0].className = zeroValue.slice(0, -1);
  
  };
  </code></pre>
  
  <p>Unfortunately this doesn't work. Another problem with this is that if the number is under 3 digits long it removes too many digits. This is what I want to happen if the sum of dice rolled is 123:</p>
  
  <pre><code>getZero[2].className = "one";
  getZero[1].className = "two";
  getZero[0].className = "three";
  </code></pre>
  
  <p>How can I achieve this? Please add code to your answer as I am new to javaScript.</p>