Fullstack path project Lodash invert() method has extra test?


I’m working on the Fullstack path project for Javascript Syntax part II, Lodash. I’ve hit step 23, “implement invert()” and there seems to be an extra test in the test/invert.js that doesn’t show up in the walkthrough video.

I’ve gone through the project with the walkthrough and created the method as she does it, and it fails the final test. I’ve noticed that the walkthrough video doesn’t have this final code test - screenshots here:

note, only three tests.

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


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.

I can manually go into the test/invert.js file and remove that test, but I don’t think that’s really what is being asked of me!

Please advise what to do in this case.



Hi everyone,

I just checked the comments underneath the youtube video and user Fjodor Jevsejev had this code that solves the code and passes the tests.

invert(object) {
      let invertedObject = {};

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

From the comments, it sounds like there are a few issues with the code in this walkthrough, though this was the only one that I found and needed a solution for.

I’m going to keep the notifications for this on, but this looks like it’s been a lingering issue codecademy needs to fix.




Thanks for this.

Werid - my code reads exactly the same as above, except:

invertedObject[originalValue] = key;

was instead

invertedObject.originalValue = key;

in my version.

This result in the code failing the final test (No. 4)

I wonder why this is? From what I understand both ‘.originalValue’ and ‘[originalValue]’ accession should work the same.

Thank you so much … was getting stuck and tis suggestion really helped

am i missing something here with this code? keeps passing an error and im completely stumped…