Skip to content

Instantly share code, notes, and snippets.

@ryanckulp
Created January 1, 2018 21:55
Show Gist options
  • Save ryanckulp/6daabf5abe6958a35e41afecf1e626e5 to your computer and use it in GitHub Desktop.
Save ryanckulp/6daabf5abe6958a35e41afecf1e626e5 to your computer and use it in GitHub Desktop.
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