Instantly share code, notes, and snippets.

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