title: How can I implement a loop so my program doesn't crash?
body: <p>I'm a beginner and I have this Javascript problem I'm working on. I'm required to prompt the user to enter either R/r or F/f. However, I want to implement a loop so that in case they enter something else, my program doesn't crash. How would I go about doing this?</p>
  
  <pre><code>function CalculatePayroll()
  {
  employeeNumber=prompt("Please enter the employee number");
  employeeName=prompt("Please enter the employee's name");
  employeeDepartment=prompt("Please enter the employee's department");
  employeesHours=prompt("Please enter the number of hours the employee 
  worked");
  employeeTypeCode=prompt("Please enter the employee's type code: F/f or 
  R/r");
  
    if(employeeTypeCode=="R"||employeeTypeCode=="r")
    {
      RegularWorkerPayroll();
      CalculateTotalPay();
      DisplayPaySlip();
  
    }
  
    else if(employeeTypeCode=="F"||employeeTypeCode=="f")
    {
      FacultyPayroll();
      CalculateTotalPay();
      DisplayPaySlip();
    }
  }
  </code></pre>
  
  <p>I would like to have a loop implemented so that if they enter something like "b" or whatever, I can continuously prompt them until they enter the right character. I tried a couple different times but I just ended up with an infinite loop lol.</p>