LoDash project part 23-26 invert function (incorrect video answer ?)

let invertedObj = {};
for(let key in object){
invertedObj[object[key]] = key;
return invertedObj;
The answers given from the video weren’t working on VScode Chrome debugger only in the CodeCademy test environment, the solution above is the correct answer. please let me know if I’m mistaken.

You’re correct that the solution in the Codecademy video for the invert() method is incorrect. The code you posted would work.

1 Like