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