I have the below object and I want to count the empty or null values in the object and update it in a property counter of that object.
E.g. I have this below object.
var userData = {
firstName: "Eric",
lastName: null,
age: "",
location : "San francisco",
country: "USA",
counter: 0
}
The result of iterating through this object would let us know that lastName and age is empty or null, so it should update counter: 2 indicating that 2 fields are empty.
obj userData = {
firstName: "Eric",
lastName: null,
age: "",
location : "San francisco",
country: "USA",
counter: 2
}
How can I achieve this?