Implement _check - #2556
Conversation
Thank you for the submission, @Nikhil-Verma-01! I'll review your code shortly, hang tight. |
dantharejabot
left a comment
There was a problem hiding this comment.
This is a great attempt, @Nikhil-Verma-01!
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 1 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!
| }; | ||
|
|
||
| module.exports = exports; | ||
| module.exports = exports; No newline at end of file |
There was a problem hiding this comment.
Newline required at end of file but not found.
(learn more)
Summary
Refactored calculator validation logic by implementing the
_check()helper and reusing it across all arithmetic methods.Changes Made
exports._check(x, y)to validate that both arguments are numbersTypeErrorwith existing error messages when inputs are invalidadd(),subtract(),multiply(), anddivide()to call_check()exactly onceWhy
This improves code quality by following the DRY (Don't Repeat Yourself) principle and centralizing input validation in one reusable function.
Result