0
Can you write different for loops for me?
İ know only like this Var i = 1; for (i=0; i<=5; i++) { document.write(i + "</br>"); } https://www.sololearn.com/discuss/2374370/?ref=app
7 Respostas
+ 1
Hi!
At first I have detected two errors in your code:
1) var is lowercase and in your code is the first letter of it uppercase.
2) you assign 1 to i (var i = 1) but in the loop you initialize it to 0?
Now to your question!
If you initialize i outside the loop you can write the loop as follows:
a)
var i = 1;
for (; i <= 5; i++) {....}
or without declaring i outside the function as:
b) for (var i = 1; i <= 5; i++) {.......}
c) other loops depend on the situation and on the programming language:
for example for JS:
=> for (var item in someArray) {......} or
=> for (var item of someArray) {......}
and so on.
0
5 or 6 ok for now dude or u can write as you want
0
This is not HM i cant find different for loop types in solo learn you can help me
0
Thank you so much Momo