0

I have this code and instead of

918273645546372819099

output in HTML, I want to see something like:

9

18

27 etc.

// Creating a while loop
    var myValue = 9;

    // Loop to find numbers that are multiples of nine that are less than 100
    while (myValue < 100)
    {
        if (myValue % 9 == 0)
        {
            document.write(myValue);
        }

        myValue++;
    }
Heretic Monkey
  • 10,498
  • 6
  • 45
  • 102
TheAccountant
  • 41
  • 1
  • 1
  • 3

1 Answers1

0

Add a line break or two. Furthermore, you can move the increment operator in the condition check for the while loop.

var myValue = 9;

// Loop to find numbers that are multiples of nine that are less than 100
while (myValue++ < 100)
{
    if (myValue % 9 === 0)
    {
        document.write(myValue + '<br/><br/>');
    }
}
manonthemat
  • 5,209
  • 1
  • 19
  • 43