title: Finding Maximum value in an Array of Objects where numer is a part of string, most optimal solution and write tests
body: <p>I have this code which finding max value from object array where number is part of string:</p>
  
  <pre><code>var stringArray = [
  { name: 'string 1' },
  { name: 'string 2' },
  { name: 'string 11' },
  { name: 'string 3' },
  { name: 'string 10' }
  ];
  var customModuleRe = new RegExp('\\d+');
  var getMax = function () {
      let max = 0, current;
      for (let i = 0, count = stringArray.length; i &lt; count; i++) {
          current = customModuleRe.exec(stringArray[i].name);
          if (current) {
              let num = parseInt(current[0]);
              if (!isNaN(num) &amp;&amp; num &gt; max) {
                  max = num;
              }
          }
      }
      return max;
  };
  </code></pre>
  
  <p>I must change this code to be clean, the most optimal and readable. In my opinion i need to use <code>map</code> function but i don't know how i can find max value. I've made this:</p>
  
  <pre><code>let max, current;
  getMax.map(function(a) {
      current = customModuleRe.exec(a.name);
      if (current) {
              let num = parseInt(current[0]);
              //max
          }
  });
  </code></pre>
  
  <p>Can someone help me to find the fatest solution? Maybe i need to use <code>reduce()</code>?</p>