Answer the question
In order to leave comments, you need to log in
How to do prompt validation?
How to check for an empty string (a space is also an empty string), for cancellation, for a number and for the number 0.
I can’t find the necessary information, or I’m not asking the right question.
Answer the question
In order to leave comments, you need to log in
let string = prompt(". . .", "")
// проверка на пустую строку (пробел - тоже пустая строка)
if (string.length === 0 || string === " ") . . .
// проверка на отмену (prompt() возвращает null, если была произведена отмена)
if (string === null) . . .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question