I get the “right” outputs and the program exits when it’s supposed to,
but just having trouble with having to start the counter of “bye” at 1.
Help on a bit of refactoring please – or even a much-improved way to
get there? Thank you.
bye = 1
while true
puts “Hey Sonny! It’s your lovely grandma! How are you?”
response = gets.chomp
if bye == 3
puts “BYE!”
exit 100
elsif (response.upcase == “BYE”)
puts “Huh?! I can’t hear you!”
bye = bye + 1
puts "bye = " + bye.to_s
elsif response != response.upcase
puts “No! Not since 19” + rand(30…51).to_s + “!”
bye=0
end
end