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 trialYashoda Sangapur
1,496 PointsNeed help with this code
I am not sure what exactly I am doing wrong, It is giving me syntax error
Thanks
def check_speed(car_speed)
if (car_speed >= 40 && car_speed <=50)
puts "safe"
else
puts "unsafe"
end
car_speed (45)
2 Answers
Luke Pettway
16,593 PointsI'll give you a hint and see if you can figure it out, look at your if else, statement, it might be missing something. The second hint is that car_speed is a variable, not the name of the method.
Let me know if that helps, and if not I can help walk you through how to figure out and correct those two issues.
Yashoda Sangapur
1,496 Pointsgot it.. thank you for the hints :)
def check_speed(car_speed)
if (car_speed >= 40 && car_speed <=50)
return "safe"
else
return "unsafe"
end
end
check_speed (45)
It worked
Luke Pettway
16,593 PointsAwesome!