Please I need help to understand why my code wouldn’t work with my predicate function defined and
why the code works without an explicit predicate function definition.
findKey: function(object,predicate){
//code does not pass codecademy test when I activate the predicate function definition
below by removing the comment below.
//predicate = val => {(val !== undefined)? true:false};
for (const prop in object){
let value = object[prop];
let predicateReturnValue = predicate(value);
if (predicateReturnValue) {
return prop;
}
}
return undefined;
}
link: https://gist.github.com/ef0b1964915d530cb511774c33bc6efe