Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created December 31, 2017 12:32
Show Gist options
  • Save anonymous/c70e92a3d9458ac9d8980ec74e4e5178 to your computer and use it in GitHub Desktop.
Save anonymous/c70e92a3d9458ac9d8980ec74e4e5178 to your computer and use it in GitHub Desktop.
def quiz (questions, i = 0, score = 0)
puts questions[i][0]
input = gets.chomp.downcase
if (i >= questions.length)
puts "End of quiz, you scored " + score.to_s
return
end
if (input == questions[i][1])
puts "correct answer!"
score = score + 1
else
puts "wrong answer!"
end
quiz questions i+1 score
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment