title: How to find longer Strings from an Array?
body: <p>I want to find Longer Strings from this array:</p>
  <p>const myArr = [&quot;first&quot;, &quot;second&quot;, &quot;third&quot;, &quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;, &quot;seven&quot;, &quot;eighth&quot;]</p>
  <p>in this array &quot;second&quot;,&quot;fourth&quot;,&quot;eighth&quot; has length of 6. I want to return these in an array.</p>
  <pre><code>const myArr = [&quot;first&quot;, &quot;second&quot;, &quot;third&quot;, &quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;, &quot;seven&quot;, &quot;eighth&quot;]
  
  function longerStrings(arr) {
      let largeStrings = []
      let longerWord = ''
      for (let name of arr) {
          if (name.length &gt; longerWord.length) {
              longerWord = name
              largeStrings.push(longerWord)
          }
      }
      return largeStrings
  }
  longerStrings(myArr)
  </code></pre>
  <p><strong>expected output is</strong>: [&quot;second&quot;,&quot;fourth&quot;,&quot;eighth&quot;]</p>
  <p>but returns =[&quot;first&quot;,&quot;second&quot;]</p>