Ruby - Programming Language
This course covers the basics of programming in Ruby. Work your way through the videos/articles and I'll teach you everything you need to know to start your programming journey!

Building A Guessing Game

Lesson 22
Author : 🦒
Last Updated : November, 2017


Code

Copysecret_word = "giraffe"
guess = ""
guess_count = 0
guess_limit = 3
out_of_guesses = false

while guess != secret_word and !out_of_guesses:
     if guess_count < guess_limit
          puts "Enter guess: "
          guess = gets.chomp()
          guess_count += 1
     else
          out_of_guesses = true
     end
end

if out_of_guesses
     puts "You Lose!"
else
     puts "You Win!"
end