You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lack of Input Validation and Error Handling in Calculator #1164
Lack of Input Validation and Error Handling in Calculator
Description:
The calculator currently lacks proper validation and error handling for various input cases. This can lead to unexpected behavior or incorrect results. Specifically, the following issues are present:
Division by zero is not handled, leading to undefined behavior.
Consecutive operators (e.g., 5 ++ 3) can be entered, causing calculation errors.
Multiple decimal points can be entered within a single number, leading to parsing issues.
Proposed Solution:
Implement validation checks for division by zero, multiple decimal points, and consecutive operators.
Add error handling to catch and display errors for invalid operations.
###Example Code:
functiondivide(a,b){if(b===0){alert("Error: Division by zero is undefined.");returnnull;}returna/b;}functionaddOperator(operator){if(!isNaN(display.value[display.value.length-1])){display.value+=operator;}}
Reacted by Karthik L.U, Adya Agrawal and S NIKHIL KUMAR
Activity
github-actions commentedon Nov 14, 2024
👋 @MakaremHind
Thanks for opening your first issue here! Be sure to follow the issue template!
soniSanidhya commentedon Nov 17, 2024
hey assign this to me
Fix: resolve issue thinkswell#1164
amrit-GH23 commentedon Mar 16, 2025
Hi, please assign this issue to me
bhpranit08 commentedon Apr 13, 2025
Hi, can you please assign this issue to me?
Fixed bug Lack of Input Validation and Error Handling in Calculator t…
Merge pull request #1180 from maneeshhm/issue-1164-fix
durgesh846 commentedon Sep 27, 2025
Hi, I’d like to work on this issue. Can you please assign it to me?
nikhilkumar1729 commentedon Oct 13, 2025
hey assign this to me
Azhar-ud commentedon Dec 7, 2025
Hi I’m new to open source. Can I work on this issue?
manya014 commentedon Dec 16, 2025
Hi, Can i work on this issue, i am new to open source