Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
What does this code do? im trying to learn some for loop with modulo

this is only a part of the code

What does this loop do? This is a JavaScript for loop I'm trying to learn some JavaScript with modulo in it but I can't understand this one.

for (var x = 2; x < n; x++) {
  if (n % x === 0) {
    return false;
  }
}
return true;
}
}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The above code will increment x (starting at 2) until it's 1 less than n. Each iteration, it checks if "n" can be evenly divided by "x". (Modulos are used to find the remainder). If it is evenly divisible, the program return false.

This code is a prime number checker. If it gets to the bottom it means "n" can only be divided by itself and returns true.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda