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

168
Vistas
why it is ignoring the number 7?

This code is supposed to skip the number 7 because there is a declaration of var using === operator. My question is what do we need to make it include number 7. Is it because it has been declared as variable and hence its ignoring it. 7 can be a variable right? or is it an integer value ?

<!DOCTYPE html>
<html>
    <body>
          
<p>A loop with a <mark>continue</mark> statement.</p>
  
  
          
<p>loop will skip the iteration where k = 7.</p>
  
  
        <p id="maddy"></p>
  
  
        <script>
            var text = "";
            var k;
            for (k = 0; k < 10; k++) {
                if (k === 7) {
                    continue;
                }
                text += "The number is " + k + "<br>";
            }
            document.getElementById("maddy").innerHTML = 
              text;
        </script>
    </body>
</html>

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

0

Just remove the if statement that checks whether k is 7?

<!DOCTYPE html>
<html>
    <body>
          
<p>A loop with a <mark>continue</mark> statement.</p>
  
  
          
<p>loop will skip the iteration where k = 7.</p>
  
  
        <p id="maddy"></p>
  
  
        <script>
            var text = "";
            var k;
            for (k = 0; k < 10; k++) {
                text += "The number is " + k + "<br>";
            }
            document.getElementById("maddy").innerHTML = 
              text;
        </script>
    </body>
</html>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Just do a simple condition.

if (k != 7) {
   text += "The number is " + k + "<br>";
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Have a look at your logic. It is running a while loop from 1 to 10. There you are checking whether the number is 7 in the if condition and if that is true you are telling the loop to finish that iteration from that point and not to continue. So the code never reaches[document.getElementById("maddy").innerHTML = text;]. So it is not displayed.

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