Lodash Project - > the invert function

Hi,

How are you?

I couldnt figure the invert function so, followed through with the walk through video. The test doesnt run for the last point. Please help

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

return invertedObject;

},

};

1 Like

Hello,

The code in the solution video isn’t accurate, but I recently posted a breakdown of why and how to correct it here:

2 Likes

Is that line actually in the video?

Yes, I was surprised too. I thought someone copied it incorrectly until I checked the video myself:

1 Like

That explains why it keeps popping up. This project must come too early in the track since very few people spot that line as completely wrong.

The method is useful for eliminating duplicate values.

Thank you so much. Will try this.

Rgds
Trishna