Why on earth this is not working?

Hi, this is my first time posting here, i’m having troubles with ‘Find the Longest Word in a String’ from the Basic Algorithm Scripting challenges, it seems to me that the problem is not my code but rather the “codechecker” as it clearly returns what it is asked for in the challenge, but the page just keeps telling that it is incorrect so i dunno what to do, at first i complicated all out thinking that an object was needed and now that i came to this simple solution it says that it is wrong, i’m quite stressed at this point please help, i tested the code on both runkit and the challenge page and it returns the correct number but the damn page kkeps telling otherwise

//simple function that takes a string and returns the length of it's largest word
function longestWord(str) {
  const separatedStr = str.split(' ');
  let lengths = [];
  const characterCounterAppender = separatedStr.forEach(function(element) {
    lengths.push(element.length);
    return lengths;
    });
  lengths = lengths.sort(function(a, b){return b-a;});
  console.log(lengths);
  return lengths[0];
}
longestWord("The quick brown fox jumped over the lazy dog");type or paste code here

Nevermind, the problem is the name of the function…

or use math.max

function findLongestWordLength(str) {
 let strLength=[];
 str.split(" ").forEach((elem,index) => strLength.push(elem.length))
 return(Math.max(...strLength))
}

findLongestWordLength("The quick brown fox jumped over the lazy dog");

We’re trying to avoid posting full copy-paste solutions to problems in the forums. In the future, please place your solutions between the [spoiler][/spoiler] tags (yes, using square brackets).

Also, if you find yourself doing .push in a loop, chances are you’re looking for Array.map.