The Faulty Calculator takes two numbers and one arithmetic operator from the user.
Normally, it performs the correct calculation, but 10% of the time it deliberately performs a wrong operation.
This project is designed purely for learning and practice purposes.
- Takes two numbers as input from the user
- Takes one operator (+, -, *, /)
- Generates a random number using
Math.random() - If the random value is less than
0.1, a faulty operation is performed - Otherwise, the correct operation is executed
| User Operator | Faulty Operation |
|---|---|
+ |
- |
* |
+ |
- |
/ |
/ |
** (Power) |
- JavaScript Functions
- Conditional Statements (
if-else) Math.random()for probability logic- User input using
prompt() - Console output
- Open the project in a browser
- Open Developer Console (Press
F12) - Run the script
- Enter values when prompted
- View results in the console
This project is part of my JavaScript learning journey and focuses on building a strong foundation before moving to advanced projects.
Beginner
This project is open-source and free to use for educational purposes.