Loadash Invert object not working

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-practice-javascript-syntax-arrays-loops-objects-iterators/projects/lodash

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:

invert(object){
    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