Загрузка...

How to display a notification if the user has entered a string?

Thread in Node.js created by Hollywood May 14, 2024. 179 views

  1. Hollywood
    Hollywood Topic starter May 14, 2024 э 20,032 Oct 28, 2020
    Code
    let a = Number(prompt())
    let b = +prompt()
    if (a, b = NaN) {
    alert('Пожалуйста, введите число')
    return;
    } else {
    console.log(a + b);
    }
    Выводит NaN
     
  2. Toil
    Toil May 14, 2024 ������� ������ :coder: 3543 Nov 18, 2018
    Number.isNaN(переменная)

    JS
    let a = Number(prompt())
    let b = +prompt()

    if (Number.isNaN(a) || Number.isNaN(b)) {
    alert('Пожалуйста, введите число')
    return
    } else {
    console.log(a + b);
    }
     
    1. Hollywood Topic starter
      Toil, Спасибо :animelove:
Loading...
Top