I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (
</>) will also add backticks around text.
In the future, please create a new topic if you are having trouble with a challenge and it is best to just use the Ask for Help button located on the challenge, because it will include your code and a link to the challenge url.
Your solution has a few problems. First, you should declare the variable i in your for loop. Second, you can not assign a new value to a read-only property of an object as you are trying to do below.
If max contains the largest word length, then just return max.