...

/

Solution: Generate Lotto Numbers

Solution: Generate Lotto Numbers

Go over the implementation of the lotto number generator.

We'll cover the following...

Solution

Press + to interact
count = 0
array = []
until count == 6
lotto_number = rand(49)
lotto_number += 1
if array.include?(lotto_number)
# Number already exist"
next
end
array << lotto_number
count += 1
end
puts "Your winning lotto numbers are #{array}, good luck!"

Explanation

  • Line 3: We use the until loop instead of a while loop. This is equivalent ...