BE101 Session 1 Homework Answers
def max(numbers)
numbers.sort.last
end
puts max([50, -9, 77, 91, 34])
def fizzbuzz(num)
return "fizzbuzz" if (num % 3 == 0) && (num % 5 == 0)
return "fizz" if num % 3 == 0
return "buzz" if num % 5 == 0
num
end
(1..100).to_a.each {|n| puts fizzbuzz(n) }
def combine(array_one, array_two)
combination = {}
array_one.each_with_index do |key, index|
combination[key] = array_two[index]
end
combination
end
puts combine([:a, :b, :c], [1, 2, 3])
def america_phrase(phrase)
"#{phrase}; Only in America!"
end
puts "Enter a phrase"
input = gets.chomp
puts america_phrase(input)