Ruby Ruby Basics Conditionals "if" Statements

alan santos
alan santos
4,125 Points

Please someone can help me with this question about "if"?

I've tryed a lot but I can't see where I'm missing...please helps

def check_speed(question)
    print question+" "

def velocity(number) 
 if number > 55
    puts "to fast"
    if number < 55
    puts "to slow"
    if number == 55
    puts "normal"

puts "welcome to analize your car!"
answer=check_speed("how fast drive your car?")
puts "your car drive #{answer}km/h and this is #{velocity}"  

2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 144,854 Points

Hi Alan,

You'll be happy to know that you pretty much have the right code to pass the challenge.

However... Challenge instructions ave very specific and must be followed exactly, and this you haven't done.


  • First, you need to delete the first 4 lines and the last 3 lines of code. These were not asked for in the instructions and will automatically cause the code checker to throw an error.
  • Second, the instructions say the method should be named check_speed, but you have named yours `velocity'.
  • Third, the instructions say to print the strings, but have have puts. These are two different methods that produce two different outcomes.
  • Forth, the instruction ask for specific strings, and yours are a bit different. The first two are correct, except for a spelling error ("to" should be "too"), but the last one should be "speed OK" but you have "normal".

The actual syntax of the method is 100% correct :thumbsup:. Once you correct the above mentioned and match exactly what the instructions ask for, the challenge will pass.
Remember, in the future, that instructions must be followed to the letter. Any deviation, including but not limited to, spelling, punctuation, spacing, methods, etc., will usually result in a Bummer!, even if the syntax is correct and it works on your own machine. Also, only do what is asked... if the challenge doesn't ask for it, don't do it.

Otherwise, Good Job!
Keep Coding! :) :dizzy:

alan santos
alan santos
4,125 Points

wow! i'm really glad to hear your explanation! thank you so much! I’ve closed de workspace and started again with your tips. i’ts became perfect. thanks again! I’ll remenber your tips!

Keep helping! :)