Put the numbers 1 through 100 in ascending order using the for statement, but the number 50 shouldn't appear. How to solve?

  • 0
    <!DOCTYPE html>
    <html>
    <head>
    <title>JS</title>
    <script language="JavaScript">
    for (var a = 1; a <= 100; a++) 
    {
    if(a==50)
    {
    a.replace('')
    }	
    if(a==49) 
    {
    document.write(a++);
    }
    document.write(a + '<h2 style="color: blue">');
    }
    </script>
    </head>
    <body>
    </body>
    </html>
    JavaScript Anna Sparks, Jul 13, 2019

  • 3 Answers
  • 0
    for (let a = 1; a & lt; 100; a ++) {



    if (a === 50) {

    continue

    }

    document.write (`$ {a}`)

    }
    Juliette Keller

  • 0
    <!DOCTYPE html>
    <html>
    <head>
    <title>JS</title>
    <style>
    b {
    color: blue;
    padding: 0 3px;
    }
    </style>
    <script>
    for (var a = 1; a <= 100; a++) {
    if (a != 50) {
    document.write('<b>' + a + '</b>');
    }
    }
    </script>
    </head>
    <body></body>
    </html>
    Anonymous

  • 0
    Just write a normal loop without conditions so that ALL the numbers appear (I really didn't understand where), and then add if (a === 50) continue;

    and all
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!