This is what I came up with for the challenge. It seems to be right besides the “May the force be with you” sentence. The code does return the number 5, as it should, but it doesn’t count it as correct. Does anyone have any idea why?
var array1 = [];
function findLongestWord(str) {
var str1 = str.split(" ");
for (var i = 0; i < str1.length; i++) {
array1.push(str1[i].length);
}
var max = Math.max.apply(Math, array1);
return max;
}
findLongestWord(“May the force be with you”);