mardi 26 février 2019

If function: Multiple required conditions - either continue or stop Node continuing with the function

I am looking to do an initial check on two conditions before I continue executing my code below. If no match is returned for both I want Node.js to stop any further processing. Not sure whether I should wrap my main code within the if function or just leave this as a check at the header of the code.

myValue = 500;
nameLow = "lato";
customerValue = 450;

// Initial check
if (nameLow == 'georgia' && myValue >= customervalue) {
    // Continue executing the code within or other code outside of if function
} else {
    // make Node.js stop executing and close
}

// Main code below (only executed when both conditions match

I am unsure whether to use return, continue, break and exitprocess() in these instances

Also, how could this be done better with a ternary statement?

Aucun commentaire:

Enregistrer un commentaire