I have a set of list with checkboxes, when i click 5 checkboxes an alert message to be displayed congrates you have selected 5 options. i have to do the validation using promise. If i am not using reject, it is working fine. but if i add the code as given below, ‘reject’ code is executed and displaying error as ‘undefined’.please any one help, where i have gone wrong?
let clickvalidation = new Promise(function(resolve, reject) {
$('input[type=checkbox][id=chk1]').change(function() {
if ($(this).is(':checked')) {
noOfClick++;
if(noOfClick==5){
resolve();
}else{
reject();
}
}
});
});
clickvalidation
.then(function () {
console.log('Success, You are a GEEK');
alert(`Congrats 5 tasks have been successfully completed`);
})
.catch(function (e) {
console.log(e.stack);
});