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

126
Views
My Simple JavaScript code using isNaN is not working

I am taking introductory JavaScript course, and I learned about isNaN function. I wrote a simple program where JS repeat prompt method unless user type number in the prompt. I don't know why my code doesn't work as I expected. If you input on the prompt twice, the program automatically escapes while loop.

<script>
    
     var userSalary = prompt("Hi, type a number!");

    
    while(isNaN(userSalary)){
        parseFloat(prompt(userSalary+ " is not number..."));
        userSalary.reset()
    }
    
    alert("Thank you!");
    
        
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You aren't setting the value of userSalary in the loop:

var userSalary = prompt("Hi, type a number!");

while(isNaN(userSalary)){
    userSalary = parseFloat(prompt(userSalary + " is not number..."));
}
alert("Thank you!");
about 4 years ago · Juan Pablo Isaza Report
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!