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

137
Views
cómo generar dos números entre 0 y 4 en javascript, pero asegúrese de que los números no sean iguales

Estoy tratando de generar dos números entre 0 y 4 en javascript, pero no quiero que los dos números sean iguales. ¿Alguna idea?

trabajando actualmente con

 state.blue_id = Math.floor(Math.random()*5); state.red_id = Math.floor(Math.random()*5); if(state.blue_id == state.red_id){ ??????? }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

¿Has considerado usar while ?

 while (state.blue_id === state.red_id) { state.blue_id = Math.floor(Math.random()*5); state.red_id = Math.floor(Math.random()*5); }
about 4 years ago · Juan Pablo Isaza Report

0

"Rechazo" es la forma estándar de manejar esto:

 state.blue_id = Math.floor(Math.random()*5); state.red_id = Math.floor(Math.random()*5); while(state.blue_id == state.red_id){ state.red_id = Math.floor(Math.random()*5); }

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!