Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

Just do a simple condition.

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

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda