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

Hello,

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.

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

returns

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.

Cheers,

coffeesp00ns

2 Likes

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.

cheers,

'spoons

8 Likes

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…

I also got stuck on this, I believe codecademy should remake the video for this lesson as it doesnt work in the editor.
looked through a bunch of resources luckily you can find this in the forums, but this will still confuse alot of beginner devs.
please fix this or link this in the lesson at the invert section

Two month later, is still here the problem. I got stuck, i cannot pass (yes, i could just don’t give a S***t) but i cannot

In anycase, thanks, this code worked, even if i dont get the real diference.

ive been banging my head against a wall for hours with this error, Glad for this post. Thank you.