From 2d4a7374e9341d9941c75d52ad032c1974691f65 Mon Sep 17 00:00:00 2001 From: Oleksandr Date: Mon, 22 Jan 2024 12:23:35 +0200 Subject: [PATCH] Solution --- src/inverseRobot.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/inverseRobot.js b/src/inverseRobot.js index 4906e020..0a86c7e5 100644 --- a/src/inverseRobot.js +++ b/src/inverseRobot.js @@ -7,7 +7,17 @@ */ function inverseRobot(robot) { - // write code here + const result = {}; + + for (const key in robot) { + if (result[robot[key]]) { + return null; + } + + result[robot[key]] = key; + } + + return result; } module.exports = inverseRobot;