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 trial
Aurelian Spodarec
7,369 PointsI dont understand the question what i need to do with it
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.
def check_speed(car_speed)
end
Aurelian Spodarec
7,369 Pointsand its also the next challenge. I just wrote return true but thats nt enought im pretty sure. It passed but i dont think its right.
notf0und
11,940 PointsFor the challenge after that, you need to check if command == 'y' and all the other ones there. If it's equal to 'y' or 'yes' or 'Y' or 'YES', return "true".
5 Answers
notf0und
11,940 PointsAlright, so the challenge asks you to make the function "check_speed" return the string "safe" if:
car_speed is at least equal to 40. So it needs to be more than or equal to 40.
and
car_speed is less than or equal to 50.
Here's the code you'll need, minus the operators:
def check_speed(car_speed)
if car_speed [operator] 40 [operator] car_speed [operator] 50
return "safe"
end
end
Does that help you?
Aurelian Spodarec
7,369 Pointsaa okay , i do understand it now , i get a bit confusing with english ;/ and i get now the challenge , i need to pause now and practice it all. Thank you
notf0und
11,940 PointsNo problem, Aurelian :)
Good luck with the rest of the course!
Aurelian Spodarec
7,369 PointsThank you :) Ijust finished Basics and this one course and now im doing codeacademy for a better understanding :) Hope you engioj treehouse :D its awesome :D no need for college :D i mean here is everyhing a boy needs :D well .. till one point xd
tth2
9,347 PointsHey Bryan, that was very helpful, thank you. If you don't mind imparting just a bit more wisdom...why do we need two 'end's? Am I right in thinking it's one end for the 'if' statement and another for the 'def'?
Danny Slewa
2,294 Pointsthe def needs an end and also the "if" needs an end. you created an "if" under the whole section of "def". need to end them both respectively.
Alexander Melo
4,297 PointsI was stuck too I didn't know you can put conditionals inside of a method. Thanks Brian!
Flavio Amiel
1,746 PointsI used this and it passed on the quiz, but it returns nothing on workspaces:
def check_speed(car_speed)
if (car_speed > 39) && (car_speed <= 50)
return "safe"
end
end
David Axelrod
36,073 PointsIm not sure why it accepts 39 but not 40.
Elias Miller
6,856 Pointsit does accept 40. Just remember to use >=
notf0und
11,940 Pointsnotf0und
11,940 PointsCan you link to the Challenge so we can help you better?