Alright then implement the objContains function: must search inside a nested object for a pair {key: value} specific. Both the object and the property name and its value will be received by parameter. In the event that it finds the indicated value at any level of the object, it must return true, otherwise return false.
Ex:
const user = {
id: 6,
email: 'homero@maxpower.com',
Personal info: {
name: 'Homer Simpson',
address: {
street: 'Avenue AlwaysLive',
number: 742,
neighborhood: 'Springfield',
state: 'Massachusetts'
}
}
}
Case that returns true -> objContains (user, "neighborhood", "Springfield");
Case that returns false -> objContains (user, "employment", "Employee in nuclear plant");
Hint: use typeof to determine if the value of a property is an object to apply there the recursion
this is what i've try
var objContains = function (obj, prop, value) {
object var = prop.value
if (typeof prop.value === obj) {
var current = this.value;
objContains (object, prop, current)
} else if (this.prop === prop && prop.value === value) {
return true;
} else {
return false;
}
}
AssertionError: expected false to equal true
32 | }
33 | it ('It should return true if it finds the property and its correct value', fun
ction () {
> 34 | expect (objContains (user, "neighborhood", "Springfield")). to.equal (true);
35 | });
36 | it ('Should return false if the property is NOT found', function () {
37 | expect (objContains (user, "employment", "Employee at nuclear power plant")). to.equal (
false);