Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr-Vol committed Jan 22, 2024
1 parent 2d4a737 commit 860ee8c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/inverseRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
*/

function inverseRobot(robot) {
const result = {};
const repairedRobot = {};

for (const key in robot) {
if (result[robot[key]]) {
const objectValue = robot[key];

if (repairedRobot.hasOwnProperty(objectValue)) {
return null;
}

result[robot[key]] = key;
repairedRobot[objectValue] = key;
}

return result;
return repairedRobot;
}

module.exports = inverseRobot;

0 comments on commit 860ee8c

Please sign in to comment.