Guest User

Untitled

a guest
Dec 31st, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.39 KB | None | 0 0
  1. def quiz (questions, i = 0, score = 0)
  2.  
  3.     puts questions[i][0]
  4.     input = gets.chomp.downcase
  5.    
  6.    
  7.     if (i >= questions.length)
  8.       puts "End of quiz, you scored " + score.to_s
  9.       return
  10.     end
  11.    
  12.     if (input == questions[i][1])
  13.       puts "correct answer!"
  14.       score = score + 1
  15.     else
  16.       puts "wrong answer!"
  17.     end
  18.    
  19.   quiz questions i+1 score
  20. end
Advertisement
Add Comment
Please, Sign In to add comment