Hello everyone,
In the video Javascript The Lodash Project at the minute 23:00 is shown the resolution of the task 25, Project Lodash in "Practice Javascript Syntax: Arrays, Loops, Objects, Iterators - 6. JavaScript Syntax, Part II of the Front-End Engineer Path Here the link
Here the code shown in the resolution of the exercise:
invert: function (object)
{
let invertedObject = {}
for (let key in object)
{
//invertedObject[object[key]] = key
const originalValue = object[key]
invertedObject = {originalValue: key}
}
return invertedObject
}
which even though passes succesfully the node test/invert.js returns in fact a wrong object
Here my code which returns the correct object
invert: function (object)
{
let invertedObject = {}
for (let key in object)
{
invertedObject[object[key]] = key
}
return invertedObject
}