My Javascript calculator

My Javascript calculator
0

#1

HI! This is my JS calculator project https://codepen.io/BLBaylis/full/NadqOa. I would appreciate feedback and critique, mainly on the functionality of it.

I’m not very experienced in CSS and want to brush up on it, so I can come back and spruce up my projects a bit later. However, if you do have advice on CSS it is also welcome and appreciated.

I’ve learnt that the eval() function exists after I finished the JS, meaning my method is quite convoluted and likely buggy. If you have any advice about systematically debugging my calculator, or of course find one yourself, this would also be very helpful.

Thank you!


#2

Hey there.

You should do some checks for invalid input. I should’ be allowed to do stuff like 6+++///--+/*+ for example!


#3

Thanks for the response! Could you elaborate on what you mean, I’m not sure I understand. Do you mean that the user shouldn’t be able to input a key at all if it isn’t valid?


#4

Yeah exactly. You shouldn’t allow invalid input. I’d rather have it function properly than have a nice layout :wink:


#5

Ah OK. The reason I didn’t do it originally was because this is how my Casio calculator handles it and saw this as an opportunity to be lazy. However, I think I will add this suggestion anyway as it can only help develop my skills and make my project better…

Thanks again!


#6

There are calculators that allow this behaviour? :open_mouth: Well that’s the first time I hear this. I am glad you are thinking this way and are going to improve it! You’re only getting better from this :wink:


#7

I love how it places the inputs on the top, however…I agree with TheGallery. If I click + then - on my computer calculator it replaces the + with the - sign rather than stacking!


#8

Thank you, I appreciate the encouragement :smiley: