-2

Okay, so I on my site people play with coins now the feature where you go to use the coins can be "Cheated" by using console in javascript using a string that is NaN so I wan't to know how I can filter if the string inputted in the bets are NaN and if they are not a number I wan't to pop up an error message and if they are numbers I want it to continue with the rest of the script.

Chase
  • 3
  • 1
  • Post what you've tried. Also if you typed in what you're asking here into Google you would probably get an answer in about 5 seconds. – zfrisch Jan 15 '17 at 00:22
  • Clearly didn't try to research this...and research is expected before asking questions – charlietfl Jan 15 '17 at 00:36

2 Answers2

0

If you want check that something is not a number you should use isNaN function.

 isNaN(NaN) // true
 isNaN(2) // false
maksimr
  • 4,891
  • 2
  • 23
  • 22
0
if(coins !== coins) {    
     //show alert
     console.info('coins is NaN.');
}
else {
        //do your work
}

if your are using ES6 :

Number.isNaN(coins)? console.info('coins is NaN.'):console.info('coins is Number.');
eGhoul
  • 2,490
  • 1
  • 13
  • 17