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 trialViraj Kokane
17,531 PointsPlease Help !!!
It gives me an error when I type the code...
def check_speed(car_speed)
# write your code here
if (car_speed >= 40) && (car_speed <= 50)
puts "safe"
else
puts "unsafe"
end
3 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Viraj,
You have one syntax error -- You are missing an end
statement for the function.
Also, the challenge asks you to return
the value "safe" or "unsafe." You are using puts
instead.
Add an end
and change puts
to return
and you're good to go.
Keep Coding! :)
Viraj Kokane
17,531 PointsJust Figured it out !
def check_speed(car_speed)
# write your code here
if (car_speed >= 40) && (car_speed <= 50)
return "safe"
else
return "unsafe"
end
end
Jason Anders
Treehouse Moderator 145,860 PointsGlad you figured it out. You posted a bit quicker than I. lol...
Viraj Kokane
17,531 PointsHey Jason I tried using The marksheet reference to do so using the backticks but was not able to do so. Please give me some idea
Jason Anders
Treehouse Moderator 145,860 PointsYou did it right, you just need one more enter/return
between the top sentence and the code block (there needs to be a space).
I edited your answer to show this. If you go and click 'edit answer' on your answer, you will see what I mean.
:)
Viraj Kokane
17,531 PointsThank You Jason Anders ! :)