It all depends on what you see as the spirit of the challenge: if it’s just to design an interactive calculator web UI, then you may as well build up an expression string and use eval()
. If you see it as the larger challenge of modeling a state machine, then eval is absolutely the last thing you want. In the end, it’s a toy project: have fun with it (that’s my theme of the day and the year) but move on when you’re satisfied with it, and if that means using eval, so be it.