first of all, what do you want the function to return? You want it to return the length of the longest word? Or you want it to return the WORD? If you want to return the WORD, you need to have a variable for that too, such as longestWord and assign the word to it in a cycle.
Second, after using split you get an Array, not an Object, so you should use for(... of...) instead of for (... in ...) .
Interesting, I have never heard of “for of” and “for in” loops before this question. I have always used forEach for the same functionality, guess this is a better way.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.