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
  • 11,687
  • 7
  • 53
  • 122
TheAccountant
  • 71
  • 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
  • 6,101
  • 1
  • 24
  • 49