calculator-challenge's People
calculator-challenge's Issues
Calculator feedback
Code
- Your JS is really neat and well psuedo coded, it’s easy for me to look at your code and understand exactly how and why you’re taking the approach you are which is awesome!
- All your operator functions are doing exactly the same thing, you should have used one function here for all of them. Then instead of referencing each individual operator from the DOM as an id, used a
querySelectorAll
and a class to get a node list of all the operators.
const handleOperatorClick = (e) => {
num1 = parseFloat(calcOutput.value);
//Display value could just be an empty string - array isn't needed
displayValue = "";
//declare a global variable for operator and reassign this when function is invoked
operator = e.target.value
calcOutput.value = operator;
};
- As above, the display value doesn’t need to be an array - especially if you’re joining it to be a string at the end of the onNumberButtonClick? When the user clicks on a button you’re going to get a string of the number. Remember arrays are for lists of things so is not really needed. you could have just done this so that the string concatenates, which is much simpler.
const onNumberButtonClick = (e) => {
calcNumber = e.target.innerText;
displayValue += calcNumber;
calcOutput.value = displayValue;
};
Site
- Lovely clean styling as usual Kirsty, page looks great!
- Would be nice to see it would work with chaining numbers e.g 5 + 1 + 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.