Lodash project


Hello everyone.
I was working with Lodash task and somewhere in the middle of the task, where I needed to define the invert method, I faced a problem. As you can see in the attached photo, I finished the .invert() method and when I execute it, it gives me two successful statements and one unsuccessful. The second and third statements are THE SAME and yet, one is indicating that my code is written properly and the other says its not.
It would be really good if someone can clarify this one for me.
Thanks in advance


@mathink3r - I ran into the same issue, very similar code. I read and re-read the Implement task (#25) and Step 6 in there is the issue.

  1. Still within the loop, set the value at originalValue on invertedObject to be the current key.

invertedObject inside the for … in loop is adding a key/value pair to the empty invertedObject outside the for … in loop. So poor step 6 wording aside, invertedObject inside the for … in loop should be:

invertedObject = {originalValue: obj};


if you go to the console doing

var object = { ‘a’: 1, ‘b’: 2, ‘c’: 1 };

you should get { ‘1’: ‘c’, ‘2’: ‘b’ }

but in this way you don’t get it


@systemrunner14485 - When you read through Tasks associated with the _.invert() method (23, 24 & 25), it states that you are swapping the key and value for each key/value pair. You are not inverting the object. So in your example:

var object = { ‘a’: 1, ‘b’: 2, ‘c’: 1 };

should output: {1: ‘a’, 2: ‘b’ 1: ‘c’}. Thats the way I approached it and it passed the test.


this post helped me a lot. Thanks!


Well, actually that’s exactly what we are doing. The inverse of 4 is 1 over 4 and the inverse of that is 4. The inverse of key: value is value: key and of course the inverse of that is key: value, again.

The member does correctly show the inverse, but also shows a change in order which is non-applicable (trivial) since objects are not ordered to begin with.