Jump to content

4ekalov

Neophyte
  • Posts

    1
  • Joined

  • Last visited

Posts posted by 4ekalov

  1. On 11/18/2015 at 5:07 PM, DivMan said:

    Как введённое значение в prompt проверить на число?

     

    var a = +prompt('Введите число');

    Проверяем:

    var a = +prompt('Введите число'); // 33
    console.log(a); // 33 .
    console.log(typeof a); // Number .
    console.log(Number.isInteger(a)); // True .

     

    var a = +prompt('Введите число'); // 5de
    console.log(a); // NaN .
    console.log(typeof a); // Number .
    console.log(Number.isInteger(a)); // False .

     

     
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy