Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZia Khan
Courses Plus Student 9,868 PointsRuby Control structure, Else Challenge, bonking early in the morning... help
How many millon things am I doing wrong here?
car_speed = 60 speed_limit = 45 def check_speed(car_speed, speed_limit) return carspeed > speed_limit end
if check_speed > 45 puts "Slow Down" else puts "Safe travels!" end
car_speed = 60
speed_limit = 45
def check_speed(car_speed, speed_limit)
return carspeed > speed_limit
end
if check_speed > 45
puts "Slow Down"
else
puts "Safe travels!"
end
2 Answers
Shaun Dixon
10,944 PointsYou can just include your conditional statement inside the check_speed method as per below:
def check_speed(car_speed, speed_limit)
if car_speed > speed_limit
puts "Slow down!"
else
puts "Safe Travels!"
end
end
Zia Khan
Courses Plus Student 9,868 PointsBrilliant! worked like a charm, cheers!