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 trialgarycollins
7,484 Pointsi can make no sense of this question
im not sure how to complete this even looking at previous lesson
def check_speed(car_speed)
# write your code here
end
2 Answers
Jitendra Bansal
9,805 PointsQuestions is asking you to write a condition that if the car speed is greater or equal to 40 but less than or equal to 50, the condition should return "safe" otherwise it should return "unsafe"
hint: you can do this by writing an if statement with this format
if (condition 1 && condition 2) return "safe" else return "unsafe"
end
Steve Hunter
57,712 PointsHi Gary,
You've got the method skeleton looking good. Now, you want to see if the speed is between the two numbers given. You need to compare car_speed
to each of those numbers and && they both need to be true. Something like:
def check_speed(car_speed)
# write your code here
if(car_speed >= 40 && car_speed <= 50)
return "safe"
end
end
I hope that helps!
Steve.
garycollins
7,484 PointsThank you i had them in separate parentheses.
if(car_speed >= 40) && (car_speed <= 50) return "safe" else return "unsafe" end
Steve Hunter
57,712 PointsGlad you're sorted and on your way. (at a safe speed) :-)