From d9d0d0614d28c60f3a9a2c5d992a96c659e36790 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 2 Nov 2023 13:32:50 +0200 Subject: [PATCH] Solution --- src/inverseRobot.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/inverseRobot.js b/src/inverseRobot.js index 4906e020..abef73e9 100644 --- a/src/inverseRobot.js +++ b/src/inverseRobot.js @@ -7,7 +7,19 @@ */ function inverseRobot(robot) { - // write code here + const result = {}; + + for (const key in robot) { + const resultKey = robot[key]; + + if (result.hasOwnProperty(resultKey)) { + return null; + } + + result[resultKey] = key; + } + + return result; } module.exports = inverseRobot;