JSFiddle - React, Tailwind, and code Playground
JavaScript
function contains(needle,haystack) {
var result = false;
$.each(haystack,function(i,v) {
if(v == needle) {
result = true;
return !result;
}
if(typeof v == 'object') {
result = contains(needle,v);
return !result;
}
});
return result;
}
console.log(
contains(7, {a: 73, b: 8}), //false
contains(7, {a: 77, b: 7}), //true
contains(7, {a: 1, b: {a: 1, b: 1}}), //false
contains(7, {a: 1, b: {a: 1, b: {a:1, b: 7}}}) //true
)