Problems with a huge list of conditional statements

Problems with a huge list of conditional statements
0

#1

I’ve been working on my calculator and I’m having trouble implementing the rules for the interface. There are a lot of them and this whole thing resulted in a rather large list of if else statements. I have managed to keep track of them by adding in some comments that divide them into sections but it still looks rather ugly. How do you deal with that sort of thing? http://codepen.io/mkarabashev/pen/KMNEKr?editors=0010


#2

You might have the non-numeric keys invoke their own handlers instead of just sorting the input. That would let you put a name to what they’re doing, making the code self-documenting.

+10 points for using Redux in a calculator. I’m amazed you found a way to make that work.


#3

Thanks for the help. That will definitely make it much easier to understand what’s going on.