Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAshmit Pathak
4,441 PointsPlease help me to know what is going on wrong with this code
I wanna build a simple number guessing app which ends when the total tries exceeds 5 but that's really not working plz help the code i have written to do so is below:-
random_number = Random.new.rand(10)
loop do print "Please enter a number between 1 and 10 (e to exit)" answer = gets.chomp array = Array.new array.push(answer)
if array.length == 5
if answer == 'e'
print "The number was #{random_number}\n"
print "Thanks for playing\n"
break
elsif answer.to_i == random_number print "Wuhh! You got me " print "The number was #{random_number}\n" break
else print "haha! you couldn't find me...\n" break
end end
end