Lodash project Help Me please

Hello i came into a situation and i cant see the problem can anyone help me…
invert(object) {

let invertedObject = {};

for(let key in object) {

  const originalValue = object[key]

  invertedObject = {originalValue : key}

};

return invertedObject;

}

};

this is my code of making a method called invert… it seams everything is alright but this error alwalys come on can someone help me.
ERROR;

$ node test/invert.js
_.invert() Tests:
1 - _.invert() is defined - Passed!
2 - Returns an object with key and value inverted for a single key-value pair - Passed!
3 - Original key is not present after the key-value pairs have been inverted - Passed!
4 - Returns an object with all keys and values inverted - Failed: _.invert({originalKey: “originalValue”})[“originalKey”]) returned undefined instead of anotherKey.

Without further analysis, I think your inverted object only contains one key-value pair even if there are multiple key-value pairs in the original object.

1 Like

Yes indeed, how can i solve the problem cause i really dont understand what is wrong…

1 Like

You can add properties to an object using syntax yourObject.yourkey = yourValue.

1 Like

Im sorry but i didnd understand , can you give me a example on how i do that and where, im getting really confused :smiley:

1 Like

For example:

invertedObject.originalValue = key;

1 Like

thanks all working now …
invert(object){

let invertedObject = {};

for(let key in object){

let originalValue = object[key];

invertedObject[originalValue] = key; 

}

return invertedObject;
1 Like