The current example calculator does not allow for chaining of operations. #6130
I should clarify, it does chain operations, but only if you press equals. It does not update the value along the way like a calculator does. My mistake if this is the desired functionality.
@dwhitebud If you are referring to http://www.freecodecamp.com/challenges/build-a-javascript-calculator : I've noticed the user stories, site, and demo video are all slightly different. The chaining user story is a bit vague, which could have been intentional. However, since the demo video and the current live example on Codepen implement the solution in different ways, this could be confusing for new developers.
I'd suggest either updating the user story to be more clear on what chaining means, or to update the demo video to use the new Codepen example.
I don't have time to work on this, the example is forked off of mine to the FreeCodeCamp codepen account so the issue isn't blocked. It is working as it was originally designed, this is a new feature request.
If anyone is curious how to implement chaining, one way to do this would be using reverse polish notation (or post fix notation). It utilizes a stack to order all the operators at the end of the expression, so a (theoretically) infinite number of operations can be executed in the proper order.
The basic calculators normally "simulate" a click in the "=" when you enter the second operator, they do not worry about the polish notation, only by the order of the numbers and operators.
Something like 4 + 5 * (calculator automatically does 4 + 5) and then it does the multiplication.
Maybe that's a simpler solution than implementing the solution with the chaining using the polish notation refered by @StevePaytosh .
The current example calculator, while extremely well done from a front end perspective, does not allow for chaining of operations. Since this is now a requirement, the example should be capable of doing this.
It also has some quirks with decimal points that might want to be addressed (allows for multiple decimal points, places the decimal point at the second position until another digit has been entered)