Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Window(confirm) looping to first function on response

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!";
}
   
}
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!