Lodash FindKey question - forEach instead of for...in

Hello,

I am working through the Re-creating the Lodash Library and it’s going ok so far. I’ve come in segement 27-30 - findKey.

I understand the provided solutions uses a for…in loop as a solution. (correct presented answer)

  findKey(object, predicate) {
    for(let key in object) {
      let tempValue = object[key];
      let predicateReturnValue = predicate(tempValue);
      if(predicateReturnValue) { return key; }
    }
    return undefined;
  }

I am wondering why I cant use forEach instead? (alternative answer attemp)

   findKey(object, predicate) {
    object.forEach(key => {
      let tempValue = object[key];
      let predicateReturnValue = predicate(tempValue);
      if(predicateReturnValue) { return key; }
    });
    return undefined;
  }

This returns a console error when testing

TypeError: object.forEach is not a function

Even changing the parameters to something like object2, I still get that error. object.forEach is a function/method though

Read this;

Object.keys(object).forEach(key => {
	console.log(key);
}

I thought I would give this approach ago and it looked to be working mostly.
But found there is gotcha though using ForEach in this instance.

Running the tests always returned undefined even when it looked to be working.

Now read this;

It looks like because I cannot break out of the ForEach it will always return undefined as the last statement.

From the official MDN docs:

There is no way to stop or break a forEach() loop other than by throwing an exception. If you need such behavior, the forEach() method is the wrong tool.

Thank you.
That was a clear explanation of why forEach wont work in this instance.