Loadash Invert object not working


every time I do the node test/invert.js, I pass all the tests except the last one it says: 4 - Returns an object with all keys and values inverted - Failed: _.invert ({originalKey: “originalValue”}) [“originalKey”]) returned undfined instead of anotherKey

I watched the walk through video and changed my code to that, but it still wont work. here’s my code:

    let invertedObject = {};
    for(let key in object){
      const originalValue = object[key];
      invertedObject = {originalValue : key};
    return invertedObject;

please help me :scream:

That is a complete object. We need to create new key-value pairs on the existing object.

object[key] = value

Thank you for responding so quickly!
very helpful

1 Like