As you may have heard, @no-stack-dub-sack and @Weezlo have been hard at work building projects with testable user stories. We are looking for a few volunteers to attempt to build these based on their automated tests.
The goal is for campers to be able to build these projects step by step following user stories. This will make the projects less intimidating and more fun. Oh, and don’t worry - we’ll still have plenty of optional projects where we don’t provide you with any tests. And if you’ve previously built these projects, you don’t need to build them again.
If you’re interested in attempting this, please reply to the thread and let us know you’ve started it. The more people who want to build this, the better, as we can start gathering feedback.
Thanks, and happy coding!
Build the project here if using codepen: http://codepen.io/freeCodeCamp/pen/MJjpwO
Here’s the example project: http://codepen.io/freeCodeCamp/pen/wgGVVX
And if you want to build the project locally, just use this CDN to pull in the test suite: https://gitcdn.link/repo/freeCodeCamp/testable-projects-fcc/master/build/bundle.js
User Stories
- My calculator should contain a clickable element containing an
=
with a correspondingid="equals"
. - My calculator should contain 10 clickable elements containing one number each from 0-9, with the following corresponding IDs:
id="zero"
,id="one"
,id="two"
,id="three"
,id="four"
,id="five"
,id="six"
,id="seven"
,id="eight"
, andid="nine"
. - My calculator should contain 4 clickable elements each containing one of the 4 primary mathematical operators with the following corresponding IDs:
id="add"
,id="subtract"
,id="multiply"
,id="divide"
. - My calculator should contain A clickable element containing a
.
with a correspondingid="decimal"
. - My calculator should contain a clickable element with an
id="clear"
. - My calculator should contain an element to display values with a corresponding
id="display"
. - At any time, pressing the clear button clears the input and output values, and returns the calculator to its initialized state.
0
should be shown in the element with the id of “display”. - As I input numbers, I should be able to see my input in the element with the id of “display”.
- In any order, I should be able to add, subtract, multiply and divide a chain of numbers of any length, and when I hit
=
, the correct result should be shown in the element with the id of “display”.- Note On Calculator Logic: It should be noted that there are two main schools of thought on calculator input logic: immediate execution and formula logic (our example utilizes formula logic and observes order of operation precedence, immediate execution does not). Either is acceptable, but please note that depending on which you choose, your calculator may yield different results than ours for certain equations (see below example). As long as your math can be verified by another production calculator, please do not consider this a bug.
-
EXAMPLE:
3 + 5 x 6 - 2 / 4 =
- Immediate Execution Logic:
11.5
- Formula/Expression Logic:
32.5
- Immediate Execution Logic:
- When inputting numbers, my calculator should not allow a number to begin with multiple zeros.
- When the decimal element is clicked, a
.
should append to the currently displayed value. Two.
s in one number should not be accepted. - I should be able to perform any operation (
+
,-
,*
,/
) on numbers containing decimal points. - If 2 or more operators are entered consecutively, the operation performed should be the last operator entered.
- Pressing an operator immediately following
=
should start a new calculation that operates on the result of the previous evaluation. - My calculator should have several decimal places of precision when it comes to rounding (note that there is no exact standard, but you should be able to handle calculations like
2 / 7
with reasonable precision to at least 4 decimal places).