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 trial

Ruby Ruby Operators and Control Structures Ruby Control Structures Else challenge

Don't understand this challenge of ruby has a bug.

Set a variable called "too_fast" equal to "true" if the car_speed is faster than the speed_limit and "false" if the car_speed is less than the speed_limit.

ruby.rb
# W
car_speed = 65
speed_limit = 60


if car_speed > speed_limit
  too_fast = true
else
  too_fast = true
end

I've also put:

if car speed > speed_limit too-fast = true else too_fast = false end

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The challenge doesn't seem to be bugged.

  • You were correct when you had the else too_fast = false
  • You've changed the car_speed from 55 as it starts in the challenge to 65. This, of course, affects the outcome.

Give it another shot with these hints in mind! :sparkles:

Thanks for your response. I'll be more careful by resetting code. Your explanations are very good!

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Marguerite,

There are a couple issues with the code:

  1. You modified the values for the car_speed and speed_limit that were pre-loaded by the challenge. These need to remain what is set by the challenge.

  2. Both the if and the else are setting the variable to true. The else should be setting the variable to "false"

Fix those up and you're good to go. :)

Keep Coding! :dizzy:

Th, will be more careful in future challenges.