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

165
Views
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 answers
Answer question

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 Report

0

Just do a simple condition.

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

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 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!