Decline Everything and Accept Everything

Hi all,
I’m working on Practice Javascript Syntax Decline Everything and Accept Everything ( Practice JavaScript Syntax: Arrays, Loops, Objects, Iterators | Codecademy. I have a line of code that is giving me an unexpected token error and I don’t understand why. The full code and error will follow a brief line of code and error.
The code:
veggies.forEach(veggie) => politelyDecline(veggie);

The Error:

SyntaxError: Unexpected token

Full code:

Full Error:
/home/ccuser/workspace/intermediate-javascript-coding-challenge-using-for-each/main.js:9
veggies.forEach(veggie) => politelyDecline(veggie);
^
SyntaxError: Unexpected token .
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_nod

Any help would be greatly appreciated! I’ve been stuck here for a while. According to the MDN, my code is written with proper syntax.
Thanks,
Mel

Hi,

I think the syntax should be:

const declineEverything = (arr) => {
   arr.forEach(item => politelyDecline(item));
}

declineEverything(veggies)

You can also do:

const declineEverything = () => {
   veggies.forEach(veggie => politelyDecline(veggie));
}

declineEverything()

but this version makes less sense, since the function declineEverything() can only decline veggies in this case.

In either case the syntax should be someArray.forEach(item => someFunction(item));.

The syntax was written as such in MDN, maybe it was confused with the arrow function call?

Thank you so much! I’ve been pulling my hair out for a week over this!