Tell us what’s happening:
When I have determined the longest word it seems there are some issues in passing that longest word back to str.length which is the expected return parameter.
The browser is telling me there are problem in referencing
str.length = longestword which is a number.
Your code so far
/function findLongestWordLength(str) {
var words = str.split(' ');
var lengthOfLongestWord = 0;
for loop iteration with an if contruct where I get longestWord to hold the variable.
}
str.length = longestWord. /* is the problematic line*/
return str.length ;
}
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/80.0.3987.132 Safari/537.36
.
Challenge: Find the Longest Word in a String
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string