Re-Creating lodash library - Help!

I am facing some problems with Re-Creating ladash library https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash, the fndKey() method.

I don’t understand the concept behind setting the variable let predicateReturnValue = //calling predicate

Still within the loop, create another variable called predicateReturnValue and set it equal to the result of calling predicate with value

how to set a function as a parameter and call it inside the higher function.
please help. I think there is something I missed!

Could you share all of your code?

thank you! :smiley:
I have found it!
the concept I think. "assuming that predicate should be entered as a function like so _.findKey(array, function(m){return 'something')
so I can create a variable and set it equal to the returned value of the function like so let variable = predicate(value).

liek so

const findKey = (object, predicate) => {

    for (let key in object){

      let value = object[key];

      let predicateRetrunValue = predicate(value);

      if (predicateRetrunValue) return key;

    }

        return undefined

  },
1 Like