Suppose I have a JSON as follows
[{"skill":"java"},{"skill","js"},{"skill","jquery"}]
I need to find if the entered skill is available in JSON
function checkSearchQuery(query){
$.getJSON('assets/static/json/keywords.json',function(data){
$.each(data, function() {
if(query.toLowerCase() == this.skill.toLowerCase()) {
return true;
}
});
});
}
I am checking like this
if(checkSearchQuery("Java")) {
// Do the action
}
else {
// Do else part
}
But this seems to execute the else part always.