This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Lucy Egerton
over 10 years

[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

2 votes
Best answer

Permalink

Oops think I just answered my own question.

Replaced = with ==

points
Submitted by Lucy Egerton
over 10 years

Answer 52b7c1b09c4e9decd9000bde

0 votes

Permalink

where do you replace = with == ?

points
Submitted by Nur Zahidah
over 10 years