When using prompt a user can always click Cancel and no value will be returned.
To prevent empty values and make it more persistent:
<h2>Welcome <span id="name"></span>!</h2>
<script>
// Persistent Prompt modal
var userName;
while(!userName) {
userName = prompt("Enter your name", "");
if(!userName) {
alert("Please, we need your name!");
} else {
document.getElementById("name").innerHTML = userName;
}
}
</script>