Implement _check - #2513
Conversation
Thank you for the submission, @nayanashaji! I'll review your code shortly, hang tight. |
dantharejabot
left a comment
There was a problem hiding this comment.
This is a great attempt, @nayanashaji!
I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.
After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.
When you push your changes to your fork, I'll come back for another review.
There are 5 style guide violations in your contribution. I've marked them with inline comments for your convenience.
Please revisit your code and follow the style guide best practices.
Hint: You might be able to fix some issues automatically by running npm run lint -- --fix
All the tests are passing. Nice job!
| }; | ||
|
|
||
| exports.add = (x, y) => { | ||
| exports._check = (x,y) => { |
| }; | ||
|
|
||
| exports.add = (x, y) => { | ||
| exports._check(x,y); |
| if (typeof y !== 'number') { | ||
| throw new TypeError(`${y} is not a number`); | ||
| } | ||
| exports._check(x,y); |
| if (typeof y !== 'number') { | ||
| throw new TypeError(`${y} is not a number`); | ||
| } | ||
| exports._check(x,y); |
| if (typeof y !== 'number') { | ||
| throw new TypeError(`${y} is not a number`); | ||
| } | ||
| exports._check(x,y); |
Thank you for your feedback! I have made the requested changes. |
Implemented DRY principle to clean the code and make it more legible.
Moved the repeated checks in each function to exports._check().
Ran npm test and made sure all tests passed.
Also, thank you for guiding me through my first contribution.😊