I have a prompt at the beginning of my page, and the text of a header is changed depending on the user's input. Since clicking the Cancel button returns null and clicking the Ok button without any text entered in the field returns an empty string, I used the two checks in my code to alter the text accordingly. The issue is that the prompt isn't actually returning null when the Cancel button is clicked. It is instead returning it as a string.
Javascript:
var name = prompt("Enter your name");
var header = document.getElementById("welcome-header");
if (name !== "null" && name !== "") {
header.innerHTML = `Welcome, ${name}!`;
}
To accommodate for this, I had to actually put null in a string, as shown in the code snippet. Am I missing something?
Here's where W3 shows that it should return null.