What's wrong with this export

why it doesn’t work?

let Airplane = '';
 let availableAirplanes = [
  {
    name: "AeroJet",
    fuelCapacity: 800,
    availableStaff: ["pilots", "flightAttendants", "engineers", "medicalAssistance", "sensorOperators"],
    maxSpeed: 1200,
    minSpeed: 300,
  },
  {
    name: "SkyJet",
    fuelCapacity: 500,
    availableStaff: ["pilots", "flightAttendants"],
    maxSpeed: 800,
    minSpeed: 200,
  }
];

export let availableAirplanes = [
  {
    name: "AeroJet",
    fuelCapacity: 800,
    availableStaff: ["pilots", "flightAttendants", "engineers", "medicalAssistance", "sensorOperators"],
    maxSpeed: 1200,
    minSpeed: 300,
  },
  {
    name: "SkyJet",
    fuelCapacity: 500,
    availableStaff: ["pilots", "flightAttendants"],
    maxSpeed: 800,
    minSpeed: 200,
  }
];

This an exercise hint

export let availableAirplanes = [...];

export let flightRequirements = {...};

gives such an error:

TypeError: /home/ccuser/workspace/intermediate-javascript_modules-airplanes/airplane.js: Duplicate declaration "availableAirplanes"
  40 | 
  41 | 
> 42 | export let availableAirplanes = [

let, const (even var) are used when declaring variables.

When updating or exporting an existing variable, you shouldn’t use let, const or var.

so what about this topic… `

Export Named Exports

Named exports are also distinct in that they can be exported as soon as they are declared, by placing the keyword export in front of variable declarations.

In menu.js

export let specialty = ‘’;
export function isVegetarian() { };
function isLowSodium() { };

  1. The export keyword allows us to export objects upon declaration, as shown in export let specialty and export function isVegetarian() {} .
  2. We no longer need an export statement at the bottom of our file, since this behavior is handled above.

`
or how can I pass this exercise?

ok. now I understand no need do it twice

Those are newly declared variables which are also directly exported.

There is a difference between new and existing variables. Although you seem to have figured that out :slight_smile:

1 Like