title: Picking the largest number in an array
body: <blockquote>
    <p>Write a single function that outputs the “largest” phone number in an input array (if multiple numbers are equally large, return the last one). Assume that the phone numbers are strings of 10 digits separated by dashes.</p>
  </blockquote>
  
  <p>I wrote a function to answer the questions above. It comes out undefined. can someone help me find the error please. I feel that i am close to the answer.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var largestNumber = function(strings) {
    var ints = strings.map(function(el) {
      return el.replace(/-/g, '').split('').reduce(function(previousValue, currentValue, currentIndex, array) {
        return previousValue + currentValue;
      });
    });
  
    console.log(ints);
  
    var largest = Math.max.apply(Math, ints);
    return strings[ints.lastIndexOf(largest)];
  };
  
  console.log(largestNumber(['111-111-1111', '111-111-1112', '111-111-1113']));</code></pre>
  </div>
  </div>
  </p>