Import Named Imports

I have completed step 2 as described but the console has barfed something up. Is this a bug?

  1. Define a function displaySpeedRangeStatus() .

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

function displayFuelCapacity() {

availableAirplanes.forEach(function(element){

console.log('Fuel Capacity of ' + element.name + ': ' + element.fuelCapacity);

});

}

displayFuelCapacity();

function displayStaffStatus() {

availableAirplanes.forEach(function(element) {

  console.log(element.name + ' meets staff requirements: ' + meetsStaffRequirements(element.availableStaff, flightRequirements.requiredStaff));

});

}

displayStaffStatus();

function displaySpeedRangeStatus() {

};

/home/ccuser/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^

TypeError: /home/ccuser/workspace/intermediate-javascript_modules-airplanes/airplane.js: Duplicate declaration “availableAirplanes”
38 | };
39 |

40 | export let availableAirplanes = ;
| ^
41 | export let flightRequirements ={};
42 | export function meetsStaffRequirements(availableStaff, requiredStaff) {
43 | if (availableStaff.length >= requiredStaff) {
at File.buildCodeFrameError (/home/ccuser/node_modules/babel-core/lib/transformation/file/index.js:427:15)
at Scope.checkBlockScopedCollisions (/home/ccuser/node_modules/babel-traverse/lib/scope/index.js:398:27)
at Scope.registerBinding (/home/ccuser/node_modules/babel-traverse/lib/scope/index.js:592:16)
at Scope.registerDeclaration (/home/ccuser/node_modules/babel-traverse/lib/scope/index.js:496:14)
at Object.BlockScoped (/home/ccuser/node_modules/babel-traverse/lib/scope/index.js:244:28)
at Object.newFn (/home/ccuser/node_modules/babel-traverse/lib/visitors.js:318:17)
at NodePath._call (/home/ccuser/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/home/ccuser/node_modules/babel-traverse/lib/path/context.js:44:14)
at NodePath.visit (/home/ccuser/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/home/ccuser/node_modules/babel-traverse/lib/context.js:150:16)

  1. Import Named Imports
    10/15

Looks like you have two object declarations for availableAirplanes.
You import it from airplane.js, did you redeclare it in your current working file?

i followed step one and got the green tick…i correctly inputted step 2 and it’s crapped out.

Which was this:

right? And now you’ve got it twice according to the log. Maybe you have wrongly declared availableAirplane before, but there was no error, because you hadn’t imported it from the other file then.

OK? But if i successfully completed the previous task how would it carry over an error?? Is this a bug? Can someone fix this?

As I previously posted, if you declared it wrongly (according to the exercise) before you imported it, it wouldn’t have been wrong until you imported it.
Another thing I notice, this is your declaration from airplane.js:

let availableAirplanes = [];

That’s an array. But here:

You’re treating it as an object with available keys name and availableStaff.
Again, I think you declared an array and an object with the same name.

I don’t follow. I completed the previous exercise and the system said it was fine, hence it allowed me to carry on to the next exercise. I am now in that exercise and have received the green tick for No. 1 and when inputting the correct empty function
function displaySpeedRangeStatus() {

};
it throws up the error. I’m sure what you’re saying is correct but I don’t understand how it would let me move on to the next exercise unless the content coming from the previous exercise was correct.

I’ve filed a bug report but is there any way to actually get someone to sort this out? I’m a beginner and i’m not paying 30£ flipping quid a month to have to deal with this piss poor service…

I don’t think so. Because I don’t think it’s a bug. To me it definitely looks like you’ve done something wrong (as I described above).
It is possible that they let you through the exercise, even though you’ve done something they haven’t asked you to, because it didn’t produce an error in the code unless you imported that array and have a double declaration since.
If you can’t follow at all (maybe I’m wrong as I haven’t seen all of your code), I’m not sure you’ve understood what you’ve done so far? Then getting a green tick or an error message doesn’t make much of a difference, I’m afraid, because you wouldn’t be able to apply the learnt somewhere else.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.