diff --git a/src/inverseRobot.js b/src/inverseRobot.js index 4906e020..8c69c330 100644 --- a/src/inverseRobot.js +++ b/src/inverseRobot.js @@ -4,10 +4,26 @@ * @param {object} robot * * @return {object} -*/ + */ function inverseRobot(robot) { - // write code here + const obj = {}; + + for (const robotKey in robot) { + const key = robot[robotKey]; + const value = robotKey; + + obj[key] = value; + } + + const robotLength = Object.keys(robot).length; + const objLength = Object.keys(obj).length; + + if (robotLength === objLength) { + return obj; + } + + return null; } module.exports = inverseRobot;