Lodash - _.invert() method unexpected result


#1

Hello, recently i have been doing the Lodash project under web development. there is however 1 method that still confuses me and it is the ._invert() method. basically, the terminal claims that i have successfully passed all tests for the method (shown in the image below in bash) however, my output is shown as: { originalValue: 'd' } instead of what i though would be something more along the lines of: { 1: a'}. It appears as my originalValue variable does not display the object key and instead displays itself. I have a feeling that a fix for this is blatantly obvious, and i apologise if so, but is this output as expected, or am i doing something wrong? Any help is greatly appreciated, Thank you.

My code + output (visual studio code editor)


#2

Tests can only show that no bug was found, not that there is a lack of bugs.
Some tests are better than others. This one is extremely limited. It does for example not test if your result is === to the expected outcome, and its input only has one key-value pair. It only inspects two very specific things. The descriptions printed don’t match what it tests.

It’s not a display issue, no. You’re discarding the original value, and replacing it with that literal string.
There’s another bug too, which will become apparent if you test your function with an object containing more than one key-value pair.