Hello, I just solved this and looked over the solutions given in the forum. Here’s mine:
function findLongestWordLength(str) {
let strArr = str.split(" ");
let charNum = [];
for (let word in strArr) {
charNum.push(strArr[word].length);
}
return Math.max(...charNum);
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
console.log(findLongestWordLength("The quick brown fox jumped over the lazy dog"));
Am I a terrible person for using Math
library functions? I saw the solutions and how some people programmed finding the max
number of an array into nifty functions… I am just lazy… Sorry…