lundi 30 novembre 2015

Return true if comparison (if statement) compares a undefined value

I'm working with a form that filters data. If the user does not put in any data the id will return undefined. If not it can be used in the if statement like: if (myValue < userInputValue) which will return true/false. However if nothing is filled in it returns false (of course). Is it possible to change this to true? My alternative solution would be to check for the variables and if it is undefined assign a value myself (however choosing a max number is not very error proof): if (!userInputValue) { userInputValue = 1 }.

What would be the best way to tackle this problem?

Aucun commentaire:

Enregistrer un commentaire