Ruby Ruby Basics Conditionals A Better "check_speed" Method

silva celso
silva celso
12,060 Points

do you the solution to this task\challenge?

def check_speed(speed) if speed < 55 puts "too slow" end if speed > 55 puts "too fast" end if speed == 55 puts "speed OK" end end

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

1 Answer

Antonio De Rose
Antonio De Rose
20,857 Points

do you the solution to this task\challenge? ???

you've been asked to change the logic from the above you have written to

If we pass a speed of less than 45, check_speed should print "too slow". If we pass a speed of 45 to 60, check_speed should print "speed OK". If we pass a speed of greater than 60, check_speed should print "too fast".

so change your code accordingly.