Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
olegobiukh committed Jul 25, 2023
1 parent 90bfadd commit 101f378
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/inverseRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 101f378

Please sign in to comment.