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 trialQuanton poulo
6,361 PointsNeed Help with this objective
Set the return value of the "check_speed" method to the string "safe" depending on the following condition:
The speed passed in as an argument is at least 40. The speed passed in as an argument is less than or equal to 50. You should use the "&&" logical operator to accomplish this task.
My Code:
def check_speed(car_speed)
# write your code here
if car_speed == ( 40 && 50)
return safe
end
end
check_speed
What am I doing wrong?
thank you
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Ryan, The question actually comes from this challenge, so it just needs to be a bit different to pass.
Hi Quanton, First off, it's best to ask challenge questions directly from the challenge. Just click "Get Help" in the top-right. This will link the actually challenge with your question and make it much easier for people to help.
The challenge wants you to write the conditional to check if the speed is at least 40 but under fifty, then return the string "safe." Currently, you are checking if the speed equals 40 and 50 at the same time. To do this you will need two conditionals inside the if
statement and both must return true.
def check_speed(car_speed)
# write your code here
if car_speed >= 40 && car_speed <= 50
return "safe"
end
end
Keep Coding! :)
Ryan Duchene
Courses Plus Student 46,022 PointsThanks, Jason. I knew it was something like that but wasn't completely sure, as I didn't know what course it was. :)
Jason Anders
Treehouse Moderator 145,860 PointsAll good, I just recently finished that one, so I knew which one it was for. Just good timing. :)
Quanton poulo
6,361 PointsHi guys,
Thanks for both answers, I will look into it.
Ryan Duchene
Courses Plus Student 46,022 PointsRyan Duchene
Courses Plus Student 46,022 PointsTweaked your post to add syntax highlighting. :)