title: Expect undefined to be number: How to convert the undefined to number?
body: <p>I've been trying to figure it out for the past 3 days but was unable to come up with a solution after running several tests in Jasmine. How do I fix it so that I can pass one of the tests "Expect undefined to be a number" whereas the duration of the movies should be a number?</p>
  
  <p>I know that undefined only happens if the object property doesn't exist or if a declared variable isn't assigned a value yet. </p>
  
  <p>Here's what I did with the code </p>
  
  <pre><code>let movies = [
    {
      title: 'The Shawshank Redemption',
      year: '1994',
      director: 'Frank Darabont',
      duration: '2h 22min',
      genre: ['Crime', 'Drama'],
      rate: '9.3'
    },
    {
      title: 'The Godfather',
      year: '1972',
      director: 'Francis Ford Coppola',
      duration: '2h 55min',
      genre: ['Crime', 'Drama'],
      rate: '9.2'
    },
    {
      title: 'The Godfather: Part II',
      year: '1974',
      director: 'Francis Ford Coppola',
      duration: '3h 22min',
      genre: ['Crime', 'Drama'],
      rate: '9.0'
    }
  ]
  
  function turnHoursToMinutes(minutesArr) {
    let durationArr = minutesArr.map(currentItem =&gt; {
      let stringtime = currentItem.duration;
      if (typeof stringtime === "string" &amp;&amp; stringtime !== null &amp;&amp; stringtime !== "" &amp;&amp; stringtime !== undefined) {
      let strnumbers = stringtime.match(/\d+/g);
      let numbers = strnumbers.map(Number);
      let minutes = 0;
      if (stringtime.includes("h") &amp;&amp; stringtime.includes("min")) {
        minutes = (numbers[0] * 60) + numbers[1];
      } else if (stringtime.includes("h")) {
        minutes = numbers[0] * 60;
      } else if (stringtime.includes("min")) {
        minutes = numbers[0];
      } 
      currentItem.duration = minutes;
      return {...currentItem};
      } else if (typeof stringtime === "number") {
        return currentItem.duration;
      } else if (typeof stringtime === "undefined") {
        return currentItem.duration = 0;
      }
    });
  
    return durationArr;
  
  }
  console.log(turnHoursToMinutes(movies));
  </code></pre>
  
  <p>As you can see, I tried to add the object property as well the value like this <code>currentItem.duration = 0</code>. I thought I could cover my bases if I wrote this code. Please let me know what's wrong with my code and how to fit it.  </p>