Build a JavaScript Calculator.Should I add validation to the code?

Build a JavaScript Calculator.Should I add validation to the code?
0.0 0

#1

Hello! I’m building a JS calculator, there aren’t anything about adding validation in the project description, so here is my question: should I add it or it’ll be enough to make a simple calculator so far? I mean I want to make it, but firstly to make the calculator according to the tasks.


#2

Are you referring to W3C compliance?


#3

I think he’s asking about validating the input - making sure they enter a valid number, etc.

Although it doesn’t explicitly say it, I think you are expected to do some basic checking.


#4

Ah that makes sense now - yes it should only accept numbers.


#5

Oh, well not that I think of it, since we’re typing in on the keys on the screen, we can’t put any wrong characters in. But we can validate that it makes sense, for example, if someone typed a decimal point, I checked to make sure there wasn’t a decimal point already in the number, etc.