Skip to content

fix: handle division by zero in calculator#134

Open
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-1649e021
Open

fix: handle division by zero in calculator#134
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-1649e021

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Fixed the divide function in src/calculator.ts to throw an Error("Division by zero") when the divisor is zero
  • Added test cases in test/calculator.test.ts for normal division and division-by-zero error handling

Assumptions

  • Throwing an error is the appropriate behavior for division by zero (rather than returning Infinity or NaN)
  • The error message "Division by zero" is descriptive enough for consumers

All 5 tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants