I'm currently trying to add a rejected promise to my promises array if one of my checks fails. The problem is that the function to check if all checks are valid fails. This is my code:
let invalidPromises = [],
validationPromises = [];
if ( input.val() === "" ) {
invalidPromises.push( Promise.reject() );
} else if ( validationAllowed( invalidPromises ) )
.......
console.log( validationAllowed( invalidPromises ) );
function validationAllowed( invalidPromises ) {
Promise.all( invalidPromises ).then( () => {
return true;
} ).catch( () => {
return false;
} );
}
The output of the console.log should be false but I'm getting only undefined. Any idea what I'm doing wrong?