title: How to make a time to value function in javascript?
body: <p>I'm trying to make a function where it selects a time and converts the time in mins into a value. Here is my code and im getting a typerror in my console log.</p>
  
  <p>Please see this fiddle to see the error i am getting
  <a href="https://jsfiddle.net/tjhunt03/npLxq0hm/16/" rel="nofollow noreferrer">https://jsfiddle.net/tjhunt03/npLxq0hm/16/</a></p>
  
  <p><a href="https://i.stack.imgur.com/TpPnU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TpPnU.png" alt="enter image description here"></a></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 _slicedToArray(arr, i) {
    return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  }
  
  function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance");
  }
  
  function _iterableToArrayLimit(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
        _arr.push(_s.value);
        if (i &amp;&amp; _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n &amp;&amp; _i["return"] != null) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  
  function _arrayWithHoles(arr) {
    if (Array.isArray(arr)) return arr;
  }
  
  
  var mealBreakStringToValue = function mealBreakStringToValue(timeStr) {
    var _timeStr$match = timeStr.match(/(\d+):(\d+) ([ap]m)/),
      _timeStr$match2 = _slicedToArray(_timeStr$match, 4),
      hours = _timeStr$match2[1],
      minutes = _timeStr$match2[2],
      ampm = _timeStr$match2[3];
  
    var minutesModifier = minutes === 'mins' ? 15 : 30;
    return Number(hours) + ampmHourModifier + minutes / 60;
  };
  console.log(mealBreakStringToValue('30 mins'));</code></pre>
  </div>
  </div>
  </p>