diff --git a/src/inverseRobot.js b/src/inverseRobot.js index 4906e020..d3b20eaf 100644 --- a/src/inverseRobot.js +++ b/src/inverseRobot.js @@ -7,7 +7,19 @@ */ function inverseRobot(robot) { - // write code here + const repairedRobot = {}; + + for (const key in robot) { + const objectValue = robot[key]; + + if (repairedRobot.hasOwnProperty(objectValue)) { + return null; + } + + repairedRobot[objectValue] = key; + } + + return repairedRobot; } module.exports = inverseRobot;