Hey im 14 and new to coding and im really enjoying it but i dont understand 5/7 loop at all i youtube it and all he did was talk about it and he showed it but it makes not one bit of sense


#1

i don't even have code because I don't know how to do it


#2

It's pretty simple with code like this:

// Example of a for loop:

for (var counter = 1; counter < 11; counter++) {
console.log(counter);
}


basically what this says in English is:

'For' as long as the Variable (var) of counter, which we have given the value of 1 to, is less than (<) 11 then add another 1, so:

our Variable (counter) has a value of 1 because that's what we gave it, counter now has a value of one which is less than 11 so we now must add another 1.

The code then goes back to the beginning or 'loops' to see if the value of counter is still less than 11, as we know it now equals 2 then we can say yes the value of counter does equal less than 11 so please add 1, now counter equals 3, is that less than 11? yes so please add 1.... until it reaches counter = 11, then counter is not less than the value of 11 and so the program terminated.

Hope this helps a little, if you want any more help feel free to message back.