The .forEach Method

Hello,

I am having problems with this part of my course : https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-learn-javascript-syntax-iterators/lessons/javascript-iterators/exercises/for-each

This code I have is

fruits.forEach(fruit => console.log('I want to eat ' + fruit));

`

The question they ask me is :

Iterate over the fruits array to log I want to eat a plus the name of each fruit to the console. For example, I want to eat a mango.

You may use any form of callback you prefer.

This comes back as not being right with the following error :image

The output looks right to me and I tried: fruits.forEach(function(fruits){console.log('I want to eat ' + fruits)}) afterwards and the output looks right to me again.

looking at the instructions:

Iterate over the fruits array to log I want to eat a plus the name of each fruit to the console. For example, I want to eat a mango .

you miss the word a between eat and the fruit.

1 Like

@stetim94 ah thanks , didn’t realise that from the error and must have read to quick. Worked now thank you.

The error message is inaccurate. I will make a bug report

good to hear that you resolved the issue :slight_smile:

1 Like