mardi 13 février 2018

Can you call a property of an object using dot notation in an if else statement?

let availableAirplanes = [{
    name: 'AeroJet',
    fuelCapacity: 800,
    availableStaff: ['pilots', 'flightAttendants', 'engineers', ' 
        medicalAssistance', 'sensorOperators'],
},
    {
        name: 'SkyJet',
        fuelCapacity: 500,
        availableStaff: ['pilots', 'flightAttendants']nter code here

    }];

let flightRequirements = {
    requiredStaff: 4,
};

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

export {availableAirplanes, flightRequirements, meetsStaffRequirements};

Is it possible to use .length on the "if" part of the if-else statement?

I'm trying to learn syntax with the idea of building a meme website in the future. So understanding what I can and cannot do is essential - not just knowing the correct answer.

Sites that I looked at:

MDN W3schools

and a variety of Javascript online programs.

It seems like there is no direct answer to this.

I am simply looking for a yes or no (and if it is a yes, how to do it).

I don't see other questions on the system that match this exact question. Again, I may be incorrect as it may be on the 1000th page.

helpful link: jsfiddle

Aucun commentaire:

Enregistrer un commentaire