declineEverything() and acceptEverything()

Hi all!
I don’t understand the task at all.

my code:

const veggies = ['broccoli', 'spinach', 'cauliflower', 'broccoflower'];

const politelyDecline = (veg) => {
      console.log('No ' + veg + ' please. I will have pizza with extra cheese.');

const declineEverything = (arr, func) => {
  arr.forEach( (veg) => {

// Write your code here:
declineEverything(veggies, politelyDecline);

My code works, but answer is incorrect.
What do I need to do with function politelyDeclin()?

I guess answer is hiding here " it should NOT merely receive argument function that uses politelyDecline()"

declineEverything should only take a single parameter (arr), then forEach accept a callback function (which has already been written, politelyDecline).

forEach is taking care of of the parameter of politelyDecline, it will pass the current element of the array as argument.

so instead of defining the function within forEach, you simply pass a function by reference.

it works!

const declineEverything = (arr) => {


This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.