Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2015 00:24
Show Gist options
  • Save anonymous/0303b43a8de86c5f3470 to your computer and use it in GitHub Desktop.
Save anonymous/0303b43a8de86c5f3470 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/fcc0208647c 's solution for Bonfire: Find the Longest Word in a String
// Bonfire: Find the Longest Word in a String
// Author: @fcc0208647c
// Challenge: http://www.freecodecamp.com/challenges/bonfire-find-the-longest-word-in-a-string#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function findLongestWord(str) {
words = str.split(' ');
counts = [];
for (i=0;i<words.length;i++) {
console.log(words[i], words[i].length);
counts.push(words[i].length);
}
return Math.max.apply(Math, counts);
}
findLongestWord("The quick brown fox jumped over the lazy dog");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment