Longest String return str.length

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:

str.length is a property of the string itself, you can’t change it without changing the string

can’t you just return longestWord?

more help than this, you need to show your whole code

You are trying to assign something to string.length. = means assign the value on the right to the name on the left. As @ilenia says, you can’t do that: it’s a property that tells you the length of a specific string

Yes , thats actually became the solution. But I was confused as the template in the challenge had return str.length; which made me think that’s what should be returned.

yes my assignment doesnt make sense , which should inform about a string cannot be assigned from a numeric value.

Kind Regards