Sorry im new to this website I'm trying to make my window(confirm) prompt when a user clicks okay it will loop back to the first function is this possible? How would I do this?
function fn() {
let firstName="";
while(firstName==""){
firstName = prompt("Enter your first name:");
let lastName="";
while(lastName==""){
lastName = prompt("Enter your Last name:");
let gender="";
while(gender !== "Male" && gender !== "Female" && gender !== "m" && gender !== "f"){
gender = prompt("Male or Female?");
let ageYrs="";
while(ageYrs < 15 ||ageYrs > 100|| isNaN(ageYrs) == true){
ageYrs = prompt("What is your age?");
let pCode="";
while(pCode === '' || pCode.length <4 || pCode === null){
pCode = prompt("What is your postcode?");
let emplyStat="";
while(emplyStat !== "Employed" && emplyStat !== "Unemployed" && emplyStat !== "unemployed" && emplyStat !== "employed"){
emplyStat = prompt("Are you employed or unemployed?");
}
}
}
}
}
}
return firstName;
}
firstName = fn();
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
}