Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
6.Bonfire: Find the Longest Word in a String
function findLongestWord(str) {
str = str.split(' ');
var longestWord = '';
for (var i in str) {
if (str[i].length >= longestWord.length) {
longestWord = str[i];
return longestWord.length;
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