Skip to content

Instantly share code, notes, and snippets.

@arthur-littm
Created October 8, 2019 21:37
Show Gist options
  • Save arthur-littm/aee779fa2974aca8db5c5ac40a40c484 to your computer and use it in GitHub Desktop.
Save arthur-littm/aee779fa2974aca8db5c5ac40a40c484 to your computer and use it in GitHub Desktop.
# 1. pick a price between 1 and 10
number = rand(1..10)
# number = array.sample
puts number
guess = 0
# LOOP HERE (stop if its correct guess)
until guess == number
# ask the user for his guess
puts "Pick a number from 1 to 10"
guess = gets.chomp.to_i
# if guess is above
if guess > number
# say too high
puts "Too high"
# else
elsif guess < number
# say too low
puts "Too low"
end
end
# END LOOP
puts "You won"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment