Find the Longest Word in a String.Help

Tell us what’s happening:
What is going wrong.Can you help me?
Your code so far


function findLongestWordLength(str) {
  var splitString = str.split(" ");
  var biggestWord = 0;
  for (var i = 0;
  i<splitString.length;
  i++) { if (biggestWord < splitString[i].length){
       biggestWord- splitString[i].length;
  }
  }
  return biggestWord;
}

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/67.0.3396.99 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

I’m looking at this line and I don’t see how this helps you find the longest word.
It looks like you are trying to do a subtraction?

No but I belive that was right in my code.And now what I should do?

I don’t understand why you are doing a subtraction…
Can you explain your algorithm?

I don’t do a subtraction but I belive this is right but you tell that isn’t right.

function findLongestWordLength(str) {
var splitString = str.split(" ");
var biggestWord = 0;
for (var i = 0;
i<splitString.length;
i++) { if (biggestWord < splitString[i].length){
biggestWord= splitString[i].length;
}
}
return biggestWord;
}

findLongestWordLength(“The quick brown fox jumped over the lazy dog”);
I belive this code it’s right.Right

Hi Klaudia

it looks good now. Did you try it?

try this - Apoiler Alert

function findLongestWordLength(str) {
  var biggestWord = "";
	str.split(" ").filter((el)=>{
    if(biggestWord.length < el.length){
      biggestWord = el;
    }
  })
  return biggestWord.length;
}
findLongestWordLength("The quick brown fox dddjumped over the lazy dog");

This is right Thank oyu for help.

I don’t try it but my new code it is right.But thank you also.