how can I check if all the keys in a json object equal to true? my object looks like this
success = {
"first_name": false,
"middle_name": false,
"last_name": false,
"d_o_b": false,
"sex": false,
"email": false,
"re_email": false,
"password": false,
"re_password": false
};
I proccess the object and every thing that turns out ok gets changed to true, now at the end I want to check if all are true, how can I do this? thank's :-)
Or a bit more functionally:
Object.keys(success).every(function(key) {
return success[key];
});
var everythingOK = true;
for (var i = 0; i < success.length; i++)
{
if( ! success[i])
{
everythingOK = false;
break;
}
}
if(everythingOK)
alert('Success!');
this should do ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With