Tell us what’s happening:
I think there must be a glitch with this exercise; it will take all the test cases except one. I believe I have the correct answer, but it gives me the error message, "findLongestWord(“May the force be with you”) should return 5. ". In fact, changing the test text to “May the force be with you” returns 5. What am I missing? I reviewed other posts on this subject and did not notice anybody else experiencing the same thing.
Thank you for your help!
~Jessiah
Your code so far
var newArray = [0];
function findLongestWord(str) {
array = str.split(' ');
for (i = 0; i < array.length; i++) {
newArray.push(array[i].length);
}
newArray.sort(function(a, b) {
return a - b;
});
return newArray[newArray.length - 1];
}
findLongestWord("May the force be with you");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0.
Link to the challenge: