Loops and iterators , next keyword! pls help!


#1


#2

Judging by the error message, I tried this and passed:

for i in 18..0
  next if i % 2 == 1
  print "#{i}"
end

Edit: retesting, forgot to refresh. fail.

for i in 0..18
  next if i % 2 == 1
  puts "#{18-i}"
end

Output

18
16
14
12
10
8
6
4
2
0
0..18

Still same error message. Hmmm...


#3

thank yu for replying.... it still returns this... :sob:


#4


#5

Been up two hours and just now getting some coffee into me.

for i in 0..18
  next if i % 2 == 1
  print "#{18-i}"
end

Passed this time.


#6

Okay, finally got to the bottom of it:

After a Reset, this is the code that is in the editor:

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

to which we add the line noted. It too, passes.


#7

thank yu!!... that solved it..!! :+1: :relieved: