Ruby Ruby Basics Conditionals "if" Statements

Mika Laakso
Mika Laakso
4,222 Points

What is wrong with the code?

It feels like everything is okay. What is missing? And if you could tell me how would you find a solution to this problem if you would not know the answer? Thank you.

program.rb
def check_speed(number)
  if number > 55
    print = "too fast"
  end
  if number < 55
    print = "too slow"
  end
  if number == 55
    print = "speed OK"
  end

2 Answers

Zack Mowrer
Zack Mowrer
Full Stack JavaScript Techdegree Graduate 56,382 Points

It seems you are missing an end statement for the function. Also print is a keyword not a variable, and I think they want you to use puts instead.

Try this:

def check_speed(number)
  if number > 55
    puts "too fast"
  end
  if number < 55
    puts "too slow"
  end
  if number == 55
    puts "speed OK"
  end
end
Mika Laakso
Mika Laakso
4,222 Points

Thank you, Zack. Now it works.