Don't know what's wrong with my invert

I believe your problem is with step 6: Still within the loop, set the value at originalValue on invertedObject to be the current key.

You have this in line 49: invertedObject = {originalValue: key}

This is redefining your invertedObject every time. What you really want is to just add that new inverted key to invertedObject so that if your for loop runs many times, all those key:value pairs are inverted and stored, not just the last one. Because line 49 is redefining the entire object, you see?

So instead, try: invertedObject[originalValue] = key;

2 Likes

thanks so much
it worked lol