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

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.

Are you referring to W3C compliance?

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.

1 Like

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

1 Like

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.