Created
October 22, 2015 14:04
-
-
Save siakaramalegos/ad4ad2e931cc047a5842 to your computer and use it in GitHub Desktop.
Same trivia app but using a hash instead of 2 arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pop trivia app | |
questions_answers = { | |
"Who sang Material Girl?" => "madonna", | |
"Which actor played Zoolander?" => "ben stiller", | |
"Who is not Michael Jackson's lover?" => "billie jean" | |
} | |
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | |
puts " Welcome to Sia's Really Cool Trivia App" | |
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | |
puts "\nLet's get started...\n" | |
# Do for all questions | |
# Ask a question | |
# Get an answer and check it | |
# Tell them if the answer is correct | |
questions_answers.each do |question, answer| | |
puts question | |
user_answer = gets.chomp.downcase | |
if user_answer == answer | |
puts "CORRECT!!" | |
else | |
puts "I'm sorry, you're not SMAHT." | |
end # ends if | |
end # ends the loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment