+ 1
JavaScript Loops
I was just wondering if there was a way to do a loop and stop on a certain number but only write that number that you chose. Example for(var i = 0;i<20;i++){ document.write(i); } so here is a example of a for loop but is there a way to say... land on 15 and only document 15 so instead of going 1234567891011121314151617181920 I could just land on 15 and 15 only If anyone has answers it would be greatly appreciated and thank you
1 Answer
+ 4
you could wrap an if statement inside of the loop like if(i == 15) {
document.write(i);
}