I have created a function which, when called with two arguments, checks the arguments against some supplementary data and if the return is false, returns the field.
I wish to return one of the elements if false and ignore/ return undefined if true.
getFirstInvalidField() {
const allFields = this.getPassengerDetailsFieldsRefs();
allFields[0].find(function (field){
if (!this.isValidField(field, 0)) {
return field;
}
}, this);
}
So when isValidField returns false, it should return field to the place where getFirstInvalidField() was called. This does not seem to be happening.
const firstInvalidField = this.getFirstInvalidField();
This should return field but instead returns undefined always. It seems the return field statement is not getting passed back and assigned to firstInvalidField
returnbeforeallFields[0].find(). You're returning the result into the function, but not then returning the result from the function.