Module- Why do we include the function key word?

I’m just starting the section “Intermediate Javascript Modules”- In this section, when we call function we have to use the function key word … in the sections leading up to this, we were able to remove that keyword and just call the function using the appropriate syntax. Why is that? How would I determine whether it is necessary to include the word function or not? s it if you are calling a function from another file then it has to be written? Thanks in advance.


Hello, @roboed64, and welcome to the forums.

You can read through this topic for more information, but the short answer is that the function keyword is not required by JavaScript. It is required to pass the exercises in this lesson due to the way the SCT (submission correctness test) is written.

Got it. Thanks for the link!

1 Like

Hello, @roboed64 and thanks for sharing for query with us.
I have see that, in the 3rd instruction is asking to pass an anonymous function to displayFuelCapacity() function.
In fact you are not obliged to use the function keyword. So the below code is what your code should look like when you complete the 3rd instruction without using the function keyword:

import Airplane from './airplane';

function displayFuelCapacity() {
  Airplane.availableAirplanes.forEach(() => {});

Hi @midlindner!
In fact it is correct that function keyword is not required by JavaScript.
But given the way the SCT(Submission Correctness Test) is written is also possible to use an arrow function.
Click the link below to see the code illustration:

If so, that’s great, but can you write the actual functions in ES6 syntax, and pass the SCT?

//for instance:
const displayFuelCapacity = () => {
  availableAirplanes.forEach(element => {
    console.log(`Fuel Capacity of ${}: ${element.fuelCapacity}`)

Yea your example code will pass the test in Step 4 but in Step 3 it should be like following:

const displayFuelCapacity = () => {
  availableAirplanes.forEach( () => {