title: Array value 'Undefined' after splitting string?
body: <p>I am splitting a function that is in format '0:00:00' using the colon. Once I have done this, I am doing some calculations with the separate numbers by saving them to a separate variable. The values where I am trying to access them after the .split function are giving 'undefined' and I am unsure why. </p>
  
  <p>I have tried using replace instead of split, but split is the easier way using less code to do what I want(ability to have the values separated).</p>
  
  <p>This is what my console shows when entering the time vie input box:
  <a href="https://i.stack.imgur.com/UUScM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UUScM.png" alt="enter image description here"></a>
  I think the error is being caused because of the time being updated with each key stroke so to speak instead after the whole time is entered. </p>
  
  <pre><code>calcPace(time, distance){
    var minutes = 0;
    var seconds = 0
  
  
  
    var hms = time+'';   // your input string
    var intDist = distance+'';
    intDist = parseFloat(distance, 10);
    var a = hms.split(':'); // split it at the colons
  
    // minutes are worth 60 seconds. Hours are worth 60 minutes.
    var totalMinutes = ((+a[0]) * 60) + ((+a[1])) + (+a[2] / 60);
  
    console.log(a[0]); //gives 'undefined, should be a number 0-6
  
    var paceValue = totalMinutes / intDist;
    minutes = Math.floor(paceValue);
    seconds = Math.round((paceValue - minutes) * 60);
  
    console.log(totalMinutes)
    if(seconds &lt; 10) {
          seconds = "0" + seconds;
      }
  
    var paceValue = minutes+":"+seconds;
  
    this.setState({
       pace: paceValue//paceValue
    });
  }
  </code></pre>
  
  <p>the function is being called here </p>
  
  <pre><code>handleButtonPress(){
    console.log("pressed");
    this.calcPace(this.time, this.distance);
  
  }
  </code></pre>
  
  <p>When I print paceValue, the result is NaN:NaN, as well as minutes and seconds. When checking in the array locations after the split, the values are undefined. I need there to be numbers there and the expected output would be something like '5:24' or similar.</p>