My first question here:
How come the function below can acces ‘availableStaff’ as a parameter? (Since ‘availableStaff’ is defined in availableAirplanes, I would expect to acces it as availableAirplanes.availableStaff)
—function meetsStaffRequirements(availableStaff, requiredStaff)— ((question number 7))
I am probably missing something really obvious, but I can’t figure out what it is. Thanks in advance!
Not sure I can explain this properly, but I’ll give it a go. In the exercise, when you call your meetsStaffRequirements(availableStaff, requiredStaff) function, you are doing so from within a forEach iteration of the availableAirplanes array. You are sending the availableStaff property from each “airplane” object in the array as a parameter along with the requiredStaff property of the flightRequirements object. Hopefully this helps a little.
I’m not too sure about what’s wrong with my code. Every step of the exercise got a checkmark - except the last one where I have to do the named export. Looking at the hint I can confirm my code is the same as the tutorial’s. Skipping right to the solution, though I wonder what happened there… Here is my code:
I Modules, lesson 7 why do you use [{}}] when creating an variable object and not just {}. I thought was just for arrays And {} are sufficient for objects and variables that contain multiple properties.
I accidentally messed up on step 7, I fixed the problem, but the error message is contradictive to the instructions, perhaps the wording could be changed from equals to less than? or even more sense, true instead of false…
I ponder a minor detail in the explanation of named exports. Why does the text (step 2) refer to the variable specialty (initialized as an empty string) as a string object? I thought a string was a primitive datatype, not an object.
Hey, same thing happened to me. I’m not sure if it is just different formatting from what codecademy expected. Even though the code for export{…} appears the same try to delete what you wrote for export{…} and just copy and paste the hint. It should work then.
When I submitted mine I did not have a space between the opening { and availableAirplanes and was not granted the check mark. After removing the space I was presented with the coveted check mark. Again not sure if this is just a bug in the testing or if it has to be like that.
What i have understand is that when you will call this function you will pass them argument in such a way that availableStaff is made accessiable e.g meetsStaffRequirements(availableAirplanes[0].availableStaff,flightRequirements.requiredStaff);
or you can use foreach() for passing all object element.
Some of the instruction steps in all the lessons are so vague in what they want you to do and half the time the hints seem to be wrong e.g. leaving out commas and semicolons and then adding them back on other hints. It is very frustrating!
Topic: Named Exports
Sorry guys if someone can remind/guide me what is happening here? In the following function how availableStaff and requiredStaff properties are available. It is confusing me
I know it’s a very late reply, but in Javascript wouldn’t you need return at the start of the line? Also, the conditional will evaluate to true or false, so you can just return it directly:
Not sure I understood your explanation. Where do we get that forEach method?bc its not in the code explicitly.And I checked the functionality of the code in the lesson by calling the function meetsStaffRequirements and it doesnt work(error in the screenshot)