diff --git a/src/inverseRobot.js b/src/inverseRobot.js index 4906e020..8e297134 100644 --- a/src/inverseRobot.js +++ b/src/inverseRobot.js @@ -7,7 +7,23 @@ */ function inverseRobot(robot) { - // write code here + const reversedRobot = {}; + const checkValue = {}; + + for (const key in robot) { + if (robot.hasOwnProperty(key)) { + const value = robot[key]; + + if (checkValue[value]) { + return null; + } + + reversedRobot[value] = key; + checkValue[value] = true; + } + } + + return reversedRobot; } module.exports = inverseRobot;