im trying to find a way to alert when there is a null values in an object, if its present it should alert fail and if it doesn't it continues with the another action. Currently im able to alert for each key. with this code:
var ave = {
'a': '02',
'b': '04',
'c': '',
'd': '',
'f': '07'
};
var total = 0
$.each(ave, function(key, value) {
var numbersA = total + value.length;
if (numbersA === 0) {
alert("Fail!");
} else {
alert("Pass!");
}
});
It pops up Fail! twice and Pass 3 times. i want it to alert fail even if there is single null value present in the object. Is there way to do it?
return falseon fail. Btw,''is not null,0is not null,nullis null.null !== ''as @elclanrs said. Are you looking for falsy values or just empty strings?