title: find longest word in a string
body: <p>Currently trying to figure out how to find the longest word in as string and my research has gotten me somewhere. I found a code on SO that shows the amount of alphabets in the longest word </p>
  
  <p>Example</p>
  
  <pre><code>function longest(str) {
    var words = str.split(' ');
    var longest = 0;
  
    for (var i=0;i&lt;words.length;i++) {
      if (words[i].length &gt; longest) {
        longest = words[i].length;
      }
    }
    return longest;
  }
  longest("This is Andela");
  
  //This returns 6
  </code></pre>
  
  <p>How do i edit this code such that it returns the word instead of the amount of alphabets.That is</p>
  
  <pre><code>//Returns Andela instead of 6
  </code></pre>
  
  <p>Considering i am also new to javascript</p>