INTERMEDIATE JAVASCRIPT MODULES : Lesson 6 'import'

Hi Guys,

I’m working on the ‘import’ lesson. In step 4 it says “Pass the anonymous function you created in the last step a parameter of element.”

When re-reading through the lesson (starting at the top) I saw no reference to the use of element for anything See the hint on Step 5:

function displayFuelCapacity() {
  Airplane.availableAirplanes.forEach(function(element){
  console.log('Fuel Capacity of ' + element.name + ': ' + element.fuelCapacity);
  });
}

Above we see element referenced two other times in the console.log. What is element?

I went all the way back to lesson 1 and reviewed all the lessons. Perhaps the concept of element was introduced in another class and I have just forgotten? Can you tell me where to go so that i can refresh my memory?

Thank you,

1 Like

element is a function parameter, see forEach documentation:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

1 Like

That exercise definitely has a few things mixed up.

More correctly, the function that you pass to forEach should accept one argument, the element to operate on. Element has no significant meaning other than the English word.

1 Like

thank you Guys. Makes sense.

1 Like