14. While Loop "Order of Sequence"


#1

Does the order of sequence matter?. I have i += 1 before print and it seems that the code loads much quicker. I'm not sure if it's just me or if it has to do with the codecademy console or if there is another reason for this?

There are a few subtle differences however with the construction, but both ways of doing it seem to work. Is there a preferred way? Thanks in advance.

Method 1
i = 0
while i < 50
i += 1
print i
end

Method 2
i = 1
while i < 51
print i
i += 1
end


#2

They do exactly the same thing, the only difference could be in readibility, but at this point it's more a matter of personal preference to be honest.

Personally I prefer to show only the inclusive values (aka, the ones I actually use in the loop), I find it more intuitive to read:

i = 1
while i <= 50
print i
i += 1
end

But again, this kind of details are up to personal preference.