var confirmation = confirm("Are you sure you want to enter your name?");
function confirmTrue() {
var nameInput = prompt("Great! Now enter your name:");
return nameInput;
}
if (confirmation == true) {
confirmTrue();
} else {
alert("I was hoping for a response..");
}
if (confirmTrue != null || confirmTrue != "") {
alert("Hello, " + window.nameInput);
}
}
confirmCallName();
i want to make a function where you confirm something to type your name in, and then after the input, it will greet you with the input result. but when the prompt returns true or false, there is a final alert that says "Hello, undefined". how do I make it's so that it doesnt activate when we cancel the prompt and after I confirm the input?
someone told me that the variable is inside the function. if so, how do I make it global?