FAQ: Intermediate JavaScript Modules - import

This community-built FAQ covers the “import” exercise from the lesson “Intermediate JavaScript Modules”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise import

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

This exercise should allow the use of ES6 string interpolation in the displayFuelCapacity() function. I tried this and it forced me to use concatenation (+) instead.


Agreed. I had to use the concatenation first then use string interpolation to test that it did work.

String interpolation is far much cleaner.


Agree, the entire lesson is unnecessarily strict on syntax. Suggest relaxing for alternative methods to solve the given problems according to the users own methods and not those imposed by CC.


Issue: lesson about es6 syntax doesn’t accept es6 syntax


Why do I feel that certain things about this exercise is just not right?


Intermediate JavaScript Modules needs to be redone. This lesson precompletes the entire code that corresponds to the instructions for me + the code doesn’t allow to write ES6 Syntax which is much cleaner and shorter. Not good.


This might be a more recent change but I was able to use ES6 string interpolation just fine! :slight_smile:


It works now


When doing things like this for real (as in somewhere besides this website), do you need to put the entire filepath for the file you want to import, or just the last bit like in the exercises? Also, why does the filepath start with a period for all of the ones in the examples?

1 Like

Another question:
Can anyone explain to me how the anonymous function we made in this one works? Why did a function need to be put in inside the .forEach() method, and how does it know what to use for the “element” parameter? This one just tells you what to do but doesn’t explain how any of it works, so I’m kind of lost.


Why is the code for importing the module ‘Airplane’ : import Airplane from ‘./airplane’, when there’s no file called ‘airplane’ only ‘airplane.js’ ?

I have the same question. ‘airplane’ is not a valid file name in this environment in reality…?

Now, even when using the function(element) {} syntax the exercise throws an error message… no clue on what is wrong here as the code works.

1 Like

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

1 Like

Step 5, chapter 6 states


Within the displayFuelCapacity function, use console.log() to output the element’s name and its fuel capacity. The output should look like this:

‘Fuel Capacity of + (element name) : + (element fuelCapacity)’

The output specification is wrong, seems like it is supposed to be ‘Fuel Capacity of NAME: FUELCAPACITY’

So I have:

  • Node installed,
  • file_a.js is connected in HTML
  • running local server (live server in VS code)
    still can’t get this thing running on my PC.


let Airplane = {};
Airplane.availableAirplanes = [
  name: 'AeroJet',
  fuelCapacity: 800
 {name: 'SkyJet',
  fuelCapacity: 500
export default Airplane;


import Airplane from "./file_a.js";
function displayFuelCapacity() {
  Airplane.availableAirplanes.forEach(function(element) {
      "Fuel Capacity of " + element.name + ": " + element.fuelCapacity

got this error

Uncaught SyntaxError: Unexpected token 'export'

it doesn’t even run in repl.it
only works in your codecademy env

not to mention some of the code that I cut and pasted from the “Hints” didn’t work.

1 Like

I believe this is standard Unix/Linux syntax to point to the current directory. (So missionControl.js and airplane.js are in the same folder on the server.)

In Part 3 of this chapter, the text said that for require(), “the .js extension is optional and will be assumed if it is not included.”

So I’m assuming it’s the same case here?