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 trialLacie Norris
3,327 PointsNot sure what I'm doing wrong
Challenge Task 1 of 1
Using an "elsif" statement, modify the code below to check whether or not the car_speed is equal to the speed_limit. If it is, set the variable "going_speed_limit" to true.
car_speed = 55
speed_limit = 55
if car_speed < speed_limit
too_fast = false
else
too_fast = true
elsif
going_speed_limit = true
end
end
6 Answers
dxt
16,505 PointsRemember "elsif" requires a conditional statement. "else" also is the final statement. You also need only one "end" statement as the elsif is a part of the entire if conditional.
if car_speed < speed_limit
too_fast = false
elsif car_speed == speed_limit
going_speed_limit = true
else
too_fast = true
end
Benjamin Miller
4,344 Pointstry this:
car_speed = 65 speed_limit = 60 too_fast = true
if car_speed > speed_limit too_fast = true else too_fast = false end
should complete the challenge.
Hope this helps!
Lee Parham
3,173 PointsDavid is right, the order is really important when writing these conditionals.
Lacie Norris
3,327 PointsIt's still not letting me pass the challenge
Lee Parham
3,173 PointsWill you put your code in here again?
Lacie Norris
3,327 PointsI passed the challenge, this is my code if car_speed < speed_limit too_fast = false elsif car_speed = speed_limit going_speed_limit = true else too_fast = true end