Are tests dodgy or is my code?

Hi all,

So, I have the following function:

function displayStaffStatus() {
  availableAirplanes.forEach(element => {
    console.log(`${element.name} meets staff requirements: ${meetsStaffRequirements(element.availableStaff, flightRequirements.requiredStaff)}`);
  });
}

Which does not get accepted as valid. Then, I have the function in the Hints which is accepted:

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

The only differences are that I use an arrow function as a parameter for the “forEach” and that I am using template literals instead of string concatenation. I am not sure if there is something wrong, or which are the finesse things and differences between my function and the one suggested.

The way I see it I should aim to write as few lines of code as possible and try to use modern methods, shorthands, etc, when writing my code, as to have is small and efficient.

It is entirely possible that the SCT for the exercise only accepts the concatenated version. What I do in these cases, is give the SCT what it wants to pass the step, then change it to what I want. :wink:

1 Like

Thank you bud. Also, a massive happy birthday :slight_smile:
That is what I ended up doing in the end, just copying and pasting from the hints. Even in instances where my code was identical, to the letter, I still got the same errors, until I copied the Hint.

1 Like