webdevsimplified / vanilla-javascript-calculator Goto Github PK
View Code? Open in Web Editor NEWPure vanilla JavaScript calculator using modern ES6 syntax and classes
Pure vanilla JavaScript calculator using modern ES6 syntax and classes
`if (number === '.' && this.currentOperand.includes('.')) return`
should be
if (number === '.' && this.currentOperand.toString().includes('.')) return
otherwise, appending a dot is not possible after a equalsButton compute()
I noticed that the calculator cannot process negative number as first input.
I tried to built the feature, but after hours and hours of trial and error, i yield.
this task is beyond my scope of understanding, i someone with more experience
try to built it ?
it would really help me an others that recently learning to code and want to dive deeper
in the universe.
best regards,
rshanTD
I want to add keypress in the calculator. so that if someone presses numbers from keyboard also it should work.
Please assign me this task so can i start working on it.
When we have selected an operation to Compute the result we can't change it to another Operation. The only way is to either clear or evaluate.
Steps to Replicate the issue
When I divide 0 by 0 it breaks until I press AC. Dividing 3 by 8 gives infinity but 0 by 0 gives nothing and it stops working.
const numberButtons= document.querySelectorAll('[data-number]')
0.1 + 0.2 and dividing by zero are giving the incorrect result. I know it is a JS fault, but I was hoping to find a solution here.
case '÷': if(curr == '0') { compute = '0'; } else{ compute = prev / curr; } break;
Cannot add an error message because for divide by zero as we are using getDisplayNumber() method to edit current operand. Hope this works
It didn't work
Vanilla-JavaScript-Calculator/script.js
Line 89 in 1a448ba
Vanilla-JavaScript-Calculator/script.js
Line 89 in 1a448ba
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.