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 trialalan santos
4,125 PointsPlease someone can help me with this question about "if"?
I've tryed a lot but I can't see where I'm missing...please helps
def check_speed(question)
print question+" "
gets.chomp
end
def velocity(number)
if number > 55
puts "to fast"
end
if number < 55
puts "to slow"
end
if number == 55
puts "normal"
end
end
puts "welcome to analize your car!"
answer=check_speed("how fast drive your car?")
puts "your car drive #{answer}km/h and this is #{velocity}"
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Alan,
You'll be happy to know that you pretty much have the right code to pass the challenge.
However... Challenge instructions ave very specific and must be followed exactly, and this you haven't done.
So,
- First, you need to delete the first 4 lines and the last 3 lines of code. These were not asked for in the instructions and will automatically cause the code checker to throw an error.
- Second, the instructions say the method should be named
check_speed
, but you have named yours `velocity'. - Third, the instructions say to
print
the strings, but have haveputs
. These are two different methods that produce two different outcomes. - Forth, the instruction ask for specific strings, and yours are a bit different. The first two are correct, except for a spelling error ("to" should be "too"), but the last one should be "speed OK" but you have "normal".
The actual syntax of the method is 100% correct . Once you correct the above mentioned and match exactly what the instructions ask for, the challenge will pass.
Remember, in the future, that instructions must be followed to the letter. Any deviation, including but not limited to, spelling, punctuation, spacing, methods, etc., will usually result in a Bummer!
, even if the syntax is correct and it works on your own machine. Also, only do what is asked... if the challenge doesn't ask for it, don't do it.
Otherwise, Good Job!
Keep Coding! :)
alan santos
4,125 Pointswow! i'm really glad to hear your explanation! thank you so much! I’ve closed de workspace and started again with your tips. i’ts became perfect. thanks again! I’ll remenber your tips!
Keep helping! :)