Skip to content

Instantly share code, notes, and snippets.

@ryanckulp
Created January 1, 2018 21:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
method with addition operation in Ruby
def addition_problem(user_answer, correct_answer)
if user_answer == correct_answer
alert "Correct!"
else
alert "Incorrect!"
end
end
# question 1, answer: 4
addition_problem(3, 4) # returns 'false'
# question 2, answer: 11
addition_problem(12, 11) # returns 'false'
# question 3, answer: 10
addition_problem(10, 10) # returns 'true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment