Okay guys, I have this assignment for a beginners Javascript class and I have one that I can’t quite figure out. If someone could give me a hand, that’d be greatly appreciated.
Here’s my code:
[code=php]
for(var row = 0; row < 5; row++) {
document.write(“<p>”);
for (var col = 0; col < 10; col++) {
document.write(” * “);
}
document.writeln(“</p>”);
}
Simple, right? Now, how do I alter this so that the asterisk prints only 1 on the first line, 2 times on the second, 3 times on the third, and so on. I thought about using an Array and then starting it at 1 and add to it on each loop, but I can’t figure out how to make the Array number increase (can’t use “++” I don’t think…). Any suggestions?