Z
Z
ZAMPOREZKE2018-03-07 13:32:35
JavaScript
ZAMPOREZKE, 2018-03-07 13:32:35

Why doesn't the condition work?

I can't figure out why it doesn't work

var name = prompt("Введите ваше имя", "");

if (name != null) {
  alert(name);
}
else
{
  alert("Вы не ввели имя!");
  
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twobomb, 2018-03-07
@ZAMPOREZKE

var name = prompt("Введите ваше имя", "");

if (name.trim() != "") 
  alert(name);
else
  alert("Вы не ввели имя!");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question