I have this json with key value pairs and i am trying to know how many times that exact match of that key value pairs occurs in that json file
This is the jquery code
$(document).ready(function(){
var data = [{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "yes"},{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "yes"},{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "yes"},{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "no"},{"programmer":"yes","married": "no", "does_java": "no"}];
//get the number of times a key:value pair occurs in json
/**
I am trying to know the number of times a specific key:value pair occurs in this json.
*/
$.each(data,function(k,v){
if(v['does_java'] === 'yes'){
console.log($(data).find(v['does_java'] === 'yes').length);
//expecting 3,but displays 0
}
});
});
The key value does_java:yes
appears 3 times but in my case it displays zero.How should i go about fixing this?.