Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions beer.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

def function_age(user_age)
if user_age >= "21"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this worked, but you don't want to use strings with a comparison operator. If you're doing numeric operations, you should be converting to integers or floats

puts("Have a beer!")

#write a function that accepts a variable: age
#if age is greater than 21, display "Yay, have a beer!"
#otherwise show them a message: "Nay, don't have a beer!"
else
puts("Nope. No beer.")
end
end

#ask for the user's age
puts("How old are you?")
user_age = gets.strip

#store the user input in a variable: user_age
function_age(user_age)

#run the function with the user_age variable