given that I have the following script, how can I only count if the array item has the value defined, in the following scenario i get 3 because it counts the arrays, but how do I check if the actual array attribute of firstName or lastname is not empty, I want it to count if either first name or last name is populated.
var x = [{"firstName":"guest1fnamee","lastName":"guest1fnamee"},{"firstName":"guest2fnamee","lastName":"guest2lnamee"},{"firstName":"","lastName":""}] var noGuests = 0 for (a in x) { noGuests++ } alert(noGuests)
update My application's javascript render engine is outdated and can't use filter's.
SpiderMonkey 1.8.5
filter
(which was added to SpiderMonkey 1.6).