Don-Alex Antoine1,886 Points
I am getting a void value expression when I run this
def repeat(string, times) counter = 0 loop do print string counter++ if (counter == times) break end end end puts repeat(Alex, 3)
Jovanny Elias14,386 Points
I have not worked with ruby in a while, But all languages pretty much work the same except for the syntax. Anyways from what I can see is that in your if statement you are not returning anything you simply stop the the function from continuing.
If you wanted to print out part of the string or do something with it you need to add that prior to ending your function inside your if statement.
Can you let us know what you want your end result to be? This would help us give you more detailed feedback.
Jay McGavrenTreehouse Teacher
repeat function doesn't return anything (well, not anything useful). So you shouldn't print its return value. Just write
repeat(Alex, 3) instead of
puts repeat(Alex, 3).