Created
April 27, 2016 01:56
-
-
Save charmainetham/2354e405552dda6b84881ba41fc7347d to your computer and use it in GitHub Desktop.
FIZZ BUZZ REFACTORING
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#first prompting user | |
puts "what number would you like to start with" | |
start = gets.chomp | |
puts "what number would you like to end with?" | |
endd = gets.chomp | |
# Define the variables | |
(start.to_i..endd.to_i).each do |i| | |
divby5 = (i % 5 == 0) | |
divby3 = (i % 3 == 0) | |
#creating cases | |
case | |
when divby5 && divby3 | |
puts "Fizzbuzz" | |
when divby3 | |
puts "Fizz" | |
when divby5 | |
puts "Buzz" | |
else | |
puts i | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment