What is the method to retrieve all values from an object and compare them?
Object :
obj = {
a : 10,
b : [{b1 : 101 , b2:201},{b3 : 102 , b4:204}],
c : [{c1 : 107 , c2:209 ,d :[{d1:109},{d2:402}]}
}
function compareValues(101,obj) {
if (retrieveValueFromObject(obj,101)) {
return true;
} else {
return false;
}
function comparator(a, b) {
return ('' + a).toLowerCase().indexOf(('' + b).toLowerCase()) > -1;
}
}
Pending: retrieveValueFromObject() needs to be implemented in a way that it loops through all key-value pairs in the object and returns a flag (true/false) if the value is found in the object.