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 trialChris Brennan
Courses Plus Student 551 PointsSet a variable called "too_fast" equal to "true" if the car_speed is faster than the speed_limit and "false" if the car_
It's telling me to put down true for car_speed is greater than speed_limit which it is not because (car_speed = 55 and speed_limit = 60) so I put down false. I put down true for the else statement because yes the speed_limit is greater than the car_speed. I'm confused yet the code I have down is right.
Plz explain why the true and false contradicts the expressions?
car_speed = 55
speed_limit = 60
# Write your code here
if
car_speed > speed_limit
too_fast = true
else
car_speed < speed_limit
too_fast = false
end
6 Answers
David Tonge
Courses Plus Student 45,640 PointsI just realized what you where asking so i deleted my answer from before but:
car_speed = represents how fast the car is going
speed_limit = represents the speed limit
too_fast (over the speed_limit) = true
too_fast (under the speed limit) = false
There isn't anything wrong with how the question is structured. If you're going over the speed limit then you're driving too fast.
Jeremi Watabiki
4,833 Pointscar_speed = 55
speed_limit = 60
if car_speed > speed_limit
too_fast = true
else
too_fast = false
end
Sorry, I know this is really old, but I didn't see a clear answer in the above responses. I just did this exercise and my above code worked fine.
David Tonge
Courses Plus Student 45,640 PointsYour answer is correct but he wasn't asking for an answer to the question. His concern was the logic of the question.
Chris Brennan
Courses Plus Student 551 PointsIt doesn't seem to matter elsif or else(tried both and it takes the code above as correct) Why do the conditions contradicts it's true and false?
Chris Brennan
Courses Plus Student 551 Pointsto me the correct answer should be:
if car_speed > speed_limit too_fast = false elsif car_speed < speed_limit too_fast = true end
not(the answer treehouse accepts)
if car_speed > speed_limit too_fast = true elsif car_speed < speed_limit too_fast = false end
James Mlambo
6,425 PointsHere is the simply answer needed. All that is being asked in this question is for you to set the too_fast variable only so below the whole code
car_speed = 65 speed_limit = 60 too_fast = car_speed > speed_limit
Annie Scott
27,613 Pointscar_speed = 65 speed_limit = 60 too_fast = true
if car_speed > speed_limit too_fast = true end
Chris Brennan
Courses Plus Student 551 PointsChris Brennan
Courses Plus Student 551 PointsDuh! smh thanks.
David Tonge
Courses Plus Student 45,640 PointsDavid Tonge
Courses Plus Student 45,640 Pointsno prob