diff --git a/package.json b/package.json index d040afd3..c0439ecb 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "license": "GPL-3.0", "devDependencies": { "@mate-academy/eslint-config": "*", - "@mate-academy/scripts": "^0.3.5", + "@mate-academy/scripts": "^1.2.8", "eslint": "^5.16.0", "eslint-plugin-jest": "^22.4.1", "eslint-plugin-node": "^8.0.1", diff --git a/src/inverseRobot.js b/src/inverseRobot.js index 4906e020..86289399 100644 --- a/src/inverseRobot.js +++ b/src/inverseRobot.js @@ -7,7 +7,19 @@ */ function inverseRobot(robot) { - // write code here + const invertedRobot = {}; + + for (const key in robot) { + const value = robot[key]; + + if (invertedRobot.hasOwnProperty(value)) { + return null; + } + + invertedRobot[value] = key; + } + + return invertedRobot; } module.exports = inverseRobot;