This forum is now read-only. Please use our new forums! Go to forums
[solved] Whats wrong with this if/else/elsif expression?
age = 17
if age = 21
puts "You can legally drink!"
elsif age < 18
puts "You cannot legally drink!"
else
puts "You can legally drink!"
end
It returns the answer “You can legally drink!”
I expect it to say “You cannot legally drink!”
Where have I gone wrong?
Alex J edited this post to fix code formatting
Answer 52ab8e3e7c82ca2914004370
Oops think I just answered my own question.
Replaced = with ==
Answer 52b7c1b09c4e9decd9000bde
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency