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

122
Views
¿Cómo escapar de un mensaje con un ciclo while con isNaN en JavaScript?

Así que mi while loop con isNaN no funciona cuando escribo un número en el prompt Aquí está mi código a continuación...

 var userSalary = prompt("Please type your salary!") while(isNaN(userSalary)){ prompt("Please type number!") } alert("Good!")

Aunque introduzco un número, no me deja escapar del bucle...

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Debe reasignar userSalary dentro del ciclo, para que el valor se actualice:

 var userSalary = prompt("Please type your salary!") while(isNaN(userSalary)){ userSalary = prompt("Please type number!") } alert("Good!")

about 4 years ago · Juan Pablo Isaza Report

0

Puede combinar las declaraciones y también probar un ciclo do..while while

 var userSalary = prompt('Please type your salary!') while (isNaN(userSalary = prompt('Please type number!'))) {} alert('Good!')

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!