Loops and Iterators; The Until Loop uses += before it's explained


#1

This slide uses the += operator in the example, and asks the user to increment the iterator "like the example above". I was OK with that b/c I already knew the += operator, but this operator isn't explained on this slide, or anywhere before so it might confuse some people.

In the next slide "More Assignment Operators" the code is reset to use the long form count = count + 1 as though that's the way we were asked to do it in the previous slide.

Anyway, it seems like Code Academy meant to use count = count + 1 in The Until Loop, and then introduce the += operator in the next slide, More Assignment Operators. It's a small over site but I wanted to point it out in case it's confusing anyone.


#2

Yes... I actually am stucked :confused:


#3

i = 20
loop do
i -= 2
print "#{i}"
break if i <= 0
end
for i in 1..20
next if i %1==0
print i
end

worked out finally.... Took me a few hours. 2 made even number not show and 2 is an even number. so I used 1 to made odd number not show, 1 is odd number. Worked


#4

I think you might have replied to the wrong thread. Did you mean to start a topic, or reply to a problem about printing out the even numbers in a loop?


#6