Import Named Imports Exercise


#1

Im stuck on step two 'define a function `displaySpeedRangeStatus()"… Im getting the following error. Cant figure it out. Pretty sure it has something to do with
the airplane.js file in exercise 9, but not sure why they let me advance to the next exercise if something was wrong.

TypeError: /home/ccuser/workspace/intermediate-javascript_modules-airplanes/airplane.js: Duplicate declaration "availableAirplanes"
  39 | 
  40 | 
> 41 | export let availableAirplanes = [];
     |            ^
  42 | export let flightRequirements = {};
  43 | export function meetsStaffRequirements(){
  44 |   };

my code: https://gist.github.com/1ec90cfa35f2a231139a464622be46db

import {availableAirplanes, flightRequirements, meetsStaffRequirements, meetsSpeedRangeRequirements } from './airplane';

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

function displayStaffStatus() {
  availableAirplanes.forEach(function(element) {
    console.log(element.name + ' meets staff requirements: ' + meetsStaffRequirements(element.availableStaff, flightRequirements.requiredStaff));
  });
};

function displaySpeedRangeStatus() {}

displayFuelCapacity();
displayStaffStatus();

my code from the airplane.js exercise:

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
 
 
}];

let flightRequirements = {
  requiredStaff: 4,
  requiredSpeedRange: 700
};

function meetsStaffRequirements(availableStaff, requiredStaff) {
  if (availableStaff.length >= requiredStaff) {
    return true;
  } else {
    return false;
  }
};

function meetsSpeedRangeRequirements(maxSpeed, minSpeed, requiredSpeedRange) {
  let range = maxSpeed - minSpeed;
  if (range > requiredSpeedRange) {
    return true
  } else {
    return false
  };
};



export let availableAirplanes = [];
export let flightRequirements = {};
export function meetsStaffRequirements(){
  };
export function meetsSpeedRangeRequirements(){};```

#2

you define availableAirplanes here:

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
 
 
}];

why would you then want to export an empty array by re-declaring availableAirplanes? Why not simple export availableAirplanes ( the one that is already defined)?


#3

I’m not really following. I think the hint (see below) provided by codecademy is throwing me off.

export let availableAirplanes = [...];

export let flightRequirements = {...};

export function meetsStaffRequirements(){
...
};

export function meetsSpeedRangeRequirements(){
...
};

#4

what about this are you not following?