Find the Longest Word in a String - getting right answers but still wrong

Hi fellow campers,

I seem to be getting right responses to the tests to this challenge but no green ticks - any ideas why?

Thanks

function findLongestWord(str) {

var split = str.split(" ");
var numList = [];
  for (var i = 0; i < split.length; i++ ) {
  array = [split[i].length];
  numList.push(array);
   
} 
numList.sort(function(a, b) {
  return a - b;
});
   return numList.pop().join();

 
}

findLongestWord("What if we try a super-long word such as otorhinolaryngology");

Turns out you were returning a string. .join returns a string.

Ah ok, that makes sense - thanks Kev

back to the drawing board :slight_smile:

Hello, I have moved your post to the right category as it is not a wiki entry.