I’m trying working on the challenge of recreating the Lodash library. I got stuck on the following object Method: findKeys()
For I still can’t figure why I can’t retrieved the key.
So far I have fulfil condition one and three, but the main one is not working.
Thanks a lot for your help =) !
Your code has overwritten the function that was passed in. It is that function that we want to invoke (one assumes), not one we create with the same name.
What is the objective of the method? Can you please post a link to the exercise so we can delve into the instructions?
Thank you for that! so here is the link:
and here it’s what the method should do:
Here is a summary of what your method should do:
.findKey() takes two arguments: an object and a predicate function — a function that returns a boolean value
.findKey() iterates through each key / value pair in the provided object and calls the predicate function with the value
.findKey() returns the first key that has a value that returns a truthy value from the predicate function
undefined if no values return truthy values from the predicate function
thanks again for your help!
Which confirms the assumption that one of the parameters is a function. Said function will supply the role expected by
A predicate is pretty straight forward. Have it look at something and return whether it is or it isn’t the desired state.
x => x.startsWith("A')
As we iterate over the keys of the object, they each become the
x in the parameter.
now see it, it makes much more sense now. I made it worked thanks to your explanation. thank you so much for your help! it was really helpful!