Find the Longest Word in a String review

Tell us what’s happening:
Can you please tell me if this approach is okay?

Your code so far

function findLongestWordLength(str) {
 const inputArr = str.split(' ');
 let outputArr = [];
 for (let i = 0; i < inputArr.length; i ++){
   outputArr[i] = inputArr[i].length;
 }  
 return Math.max.apply(null, outputArr);
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string

Looks sound from here – but did it pass?

Thanks for reply, It did. I was just wondering if the array sort approach to find max is better in terms of performance.

Your solution is fast enough. The only way your solution wouldn’t work is if you had (2 * 32) - 1 words…, then Math.max() wouldn’t work.

thank you for feedback.!