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 trialRod Ilunga
793 PointsI have no clue of what is wrong with my code. Can someone help point out what I did wrong and explain?
I'm sure I did it right but missed something.
def check_speed(car_speed)
if (car_speed == 40) && (car_speed <= 50)
return check_speed = "safe"
end
2 Answers
Tim Knight
28,888 PointsRod,
In terms of your return value you just need to return the value of "safe" under your specific condition. Additionally you need to end your conditional statement.
You could write this like so:
def check_speed(car_speed)
if car_speed >= 40 && car_speed <= 50
return "safe"
end
end
Or like this:
def check_speed(car_speed)
return "safe" if car_speed >= 40 && car_speed <= 50
end
Rod Ilunga
793 PointsThank you so much Tim! It seems I was missing a couple of things as I'm still getting the hang of methods! Your help is very much appreciated!