Learn Javascript Grammer Checker

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
https://www.codecademy.com/courses/introduction-to-javascript/projects/mini-linter

Error Message: SyntaxError: Malformed arrow function parameter list

Question: Why is it saying this? I looked at the answer and it requires a second () with the ) being outside of the {}. Why is this?

let story = 'Last weekend, I took literally the most beautifull bike ride of my life. The route is called "The 9W to Nyack" and it stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It\'s really an adventure from beginning to end! It is a 48 mile loop and it literally took me an entire day. I stopped at Riverbank State Park to take some artsy photos. It was a short stop, though, because I had a freaking long way to go. After a quick photo op at the very popular Little Red Lighthouse I began my trek across the George Washington Bridge into New Jersey. The GW is a breathtaking 4,760 feet long! I was already very tired by the time I got to the other side. An hour later, I reached Greenbrook Nature Sanctuary, an extremely beautifull park along the coast of the Hudson. Something that was very surprising to me was that near the end of the route you literally cross back into New York! At this point, you are very close to the end.';

let storyWords = story.split(' ');
let unnecessaryWord = 'literally';
let misspelledWord = 'beautifull';
let badWord = 'freaking';
//console.log(storyWords)
let count = 0;
storyWords.forEach(word) => {
  count ++;
}
console.log(count)

console.log(storyWords.join(' '));

Your ) is in the wrong place.

storyWords.forEach(word) => {
  count ++;
}

It should be

storyWords.forEach(word => {
  count ++;
});

so that the function word => count++ is a argument for the .forEach … meaning it has to be between the parenthesis.

You’re missing an opening bracket in the arrow function .forEach. It should be:

storyWords.forEach((word) => {
    count++
}

Alternatively, since you’re only using one parameter, you can just not wrap the parameter with any brackets.

1 Like

So the reason the paranthesis needs to be after the curly brace is because the entire function is being saved as an argument, and the argument syntax requires () around parameters.

Am I right or close or way off?

-strikeotus27

Yes, that’s correct. Calling a function requires the ( and ) .

Keep in mind that the argument of forEach() is a callback function.

let count = 0
array.forEach(word => count++)
                   /
         concise body function