DEV Community

Discussion on: JavaScript Calculator - The DOM way

Collapse
 
loucyx profile image
Lou Cyx

You should change those divs and use button elements for the buttons, and for the "display" maybe use an output element. Also eval is not the safest, so maybe have some kind of safe parser? Something that builds a safe function call based on numbers and operators (like if it sees 1 + 2, it actuall calls an add function passing 1 and 2 as arguments).

Cheers!

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

Agree on everything. Moreover I'd add key events so you can use it with the keyboard but... That's what happen when no planning is performed before coding 😂 I just started with a few hours countdown and that's what I came out with.
I did it for fun and I'm not sure I'll spend more time on it, let's see what happen in the next boredom episode

Some comments have been hidden by the post's author - find out more