To import objects stored in a variable, we use the import
keyword and include the variables in a set of {}
.
In the order.js file, for example, we would write:
import { specialty, isVegetarian } from './menu'; console.log(specialty);
- Here
specialty
andisVegetarian
are imported. - If we did not want to import either of these variables, we could omit them from the
import
statement. - We can then use these objects as in within our code. For example, we would use
specialty
instead ofMenu.specialty
.
Instructions
Let’s remove any reference to Airplane
in our code since we are no longer exporting this module.
For example, Airplane.availableAirplanes
should be modified to availableAirplanes
.
Again, you will see a ReferenceError
in the console for now, but we will fix that in our next step.
Change the import
statement such that it imports the availableAirplanes
, flightRequirements
, and meetsStaffRequirements
variables.
Now, modify any instance of the Airplane.availableAirplanes
variable, so that you only use availableAirplanes
.
Define a function displayStaffStatus()
.
Within the body of the displayStaffStatus()
function, use the forEach
to iterate over the availableAirplanes
array.
Specifically, the forEach()
should take a function as a parameter. The function should in turn take element
as a parameter.
Within the displayStaffStatus()
function, use console.log()
to output the element’s name. We’ll add more in the next step.
Continuing within the displayStaffStatus()
function, modify the console.log()
statement to output
(element name) + ' meets staff requirements: ' + (true/false)
To do this, we can call the meetsStaffRequirements
method, passing in two parameters element.availableStaff
and flightRequirements.requiredStaff
.
Call the displayStaffStatus()
function.