-
Notifications
You must be signed in to change notification settings - Fork 2.4k
added initial solution #2676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
added initial solution #2676
Changes from 17 commits
efa2ecd
a946d53
6831bb9
0c9c947
b67f7e2
66f7d93
412eb24
2c949bd
07d32d3
727503c
a44140d
6320c61
b589d37
408ab78
fc864ed
297f3ed
c1b5609
0d59f06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,17 @@ | |
| */ | ||
|
|
||
| function inverseRobot(robot) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good practice to add a brief comment describing what your function does. This will help other developers understand your code more easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a check to ensure that the 'robot' parameter is indeed an object and not null or undefined. This can prevent potential runtime errors if the function is called with invalid arguments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function 'inverseRobot' is correctly named and describes its purpose well. |
||
| // write code here | ||
| const invertedRobot = {}; | ||
|
|
||
| for (const key in robot) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's recommended to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
| if (robot[key] in invertedRobot) { | ||
|
||
| return null; | ||
| } | ||
|
|
||
| invertedRobot[robot[key]] = key; | ||
|
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InversedRobot, use
|
||
|
|
||
| return invertedRobot; | ||
|
||
| } | ||
|
Comment on lines
9
to
22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
|
|
||
| module.exports = inverseRobot; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's good practice to include a newline at the end of the file. Some tools and systems expect or require it for proper processing. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to add a function description using JSDoc comments. This helps other developers understand what the function does, its parameters, and its return value.