Can somebody please HELP me understand what is happening in this line of code?

Hi, guys! I’m kind of new to coding and, at the moment, I’m learning some JS and OOP. So, at this part in the exercise of “Re-creating the Lodash Library” I can’t really understand what is happening in the highlighted part of the image. I was hoping somebody could pls help me understand why this line of code is necessary and what is it doing… It is suppose to replicate the functionality of this method.

Thanks!

Help

Hi @luiz_ft
Welcome to the forum!
This function filters valid values in an object. Which values are considered valid is determined by a function that is passed to the findKey method.

findKey (object, info) { // the first parameter expects – obviously – an object, which values should be tested
// the second parameter expects a function that tests the values passed to it for validity and returns either true or false.
let value = object[key]; // value in object to be tested
let predicateValue = info(value) // test function is invoked with value to be tested. If the value passes the test, `predicateValue` is true.
...
}
2 Likes

Thanks a lot @mirja_t! :grinning:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.