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 If challenge!

Soumya Veer
Soumya Veer
3,484 Points

too_fast variable is not set. Not sure if I am understanding the task correctly.

I am getting this message 'too_fast variable is not set'. but every time I execute the code, too_fast is returning true if car_speed is > speed_limit. I am not sure if I understand the task properly.

ruby.rb
car_speed = 65
speed_limit = 60
too_fast = "false"
if car_speed > speed_limit
  too_fast = "true"
  puts "Car speed is faster than the speed limit"
end
puts too_fast

1 Answer

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

You understand the problem just fine. The problem is that you've set too_fast to the strings "true" and "false" instead of the values true and false. Just remove the quotes. See my code for clarification:

car_speed = 65
speed_limit = 60
too_fast = false
if car_speed > speed_limit
  too_fast = true
  puts "Car speed is faster than the speed limit"
end
puts too_fast