JSFiddle - React, Tailwind, and code Playground
by Emad Dehnavi
HTML
<input type="text" id="keyword" placeholder="Enter Keyword" />
<input type="button" onclick="find(keyword.value)" value="find" />
JavaScript
function find (keyword){
var obj = {
friends: [
{name: 'Steve Jon', country: 'NZ'},
{name: 'Jane Ken', country: 'US'},
{name: 'Mike Jhon', country: 'AU'},
{name: 'Mary Mani', country: 'NZ'},
],
enemies: [
{name: 'Evil Steve', country: 'AU'},
{name: 'Betty', country: 'NZ'},
]
}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
for (var subKey in obj[key]) {
if(obj[key][subKey].name.toLowerCase().search(keyword)!=-1){
alert('The keyword exist')
return true;
}
}
}
}
alert('not found');
return false;
}