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 trialalexfakrhi
6,372 PointsSeem to be struggling to come up with a solution for this problem, not actually sure what it's asking me to do!
can someone verify what the output should be, i's not very clear so I can't seem to be able to write code that passes the test.
3 Answers
alexfakrhi
6,372 PointsHi Jason,
This is what I've come up with, but the only return message is Bummer! Try again! I've tried so many variations and I can't get any to pass!
def check_speed(car_speed)
if car_speed > 39 && car_speed <= 50 return "safe"
end
end
Thanks!
Jason Anello
Courses Plus Student 94,610 PointsTry car_speed >= 40
for your 1st condition.
With your code, a speed of 39.3 could be passed in and it would return "safe" but that's not at least 40.
Jason Anello
Courses Plus Student 94,610 PointsI'm not sure if the challenge is not being strict enough here but your original code does pass with the return
on its own line.
def check_speed(car_speed)
if car_speed > 39 && car_speed <= 50
return "safe"
end
end
this would be fine if only integer car speeds were passed in.
alexfakrhi
6,372 Pointsit's strange, I tried a lot of combinations and went through the threads already covering this topic and had trouble getting it to pass but eventually it did it!
def check_speed(car_speed) if (car_speed > 40) && (car_speed <= 50) return "safe" end end
alexfakrhi
6,372 Pointsgot it to pass, changed it to >= 40, and put both conditions in parentheses, put the return on a new line too!
Thanks for the amazingly fast response guys!!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Alex,
What code have you tried so far?