zairne86
11-12-2010, 08:55 PM
Hi,
I am doing some studying and we was to create a small loop using either the for loop, while loop or do while loop. I chose to do the for loop because it was easier to understand, but I want to know how to do the same using the while loop. Here is the for loop I have, but I cant figure out how to change to while loop.
for (var i = 0; i < 5; ++i)
{
for (var j = i; j < 5; ++j)
{
document.write(j + "");
}
document.write("<br />");
}
output is equal to:
01234
1234
234
34
4
How do you make the same using a while loop?
I am doing some studying and we was to create a small loop using either the for loop, while loop or do while loop. I chose to do the for loop because it was easier to understand, but I want to know how to do the same using the while loop. Here is the for loop I have, but I cant figure out how to change to while loop.
for (var i = 0; i < 5; ++i)
{
for (var j = i; j < 5; ++j)
{
document.write(j + "");
}
document.write("<br />");
}
output is equal to:
01234
1234
234
34
4
How do you make the same using a while loop?