Section 3 (The 'UNTIL' Loop); IM STUCK!


#1

Ok, so for this particular section this is what i came up with....

counter = 1
until counter == 10
puts counter
counter += 1

end

... when i press 'save and submit code', i get every error in the book! Ive tried several different inputs to see if it will come out correctly and I still get an error message!


#2

Output for the code you posted is:

1
2
3
4
5
6
7
8
9

With no errors. I don't see any problem. Perhaps that's simply not the behaviour that the instructions ask for?


#3

When I press "save and submit", this error message appears:

"Oops, try again. It looks like your code doesn't print the numbers 1 to 10 to the console."

Im lost....


#4

That means starting at 1 but is unspecific about whether to stop before or after having printed 10, so try both if it's not said


#5

OMG,
what i was doing wrong was, i wasnt putting "puts counter" at the end of the code! That solved the problem!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.