I have written the following code to retrieve "Random Case" and "Random name". All forum advice is to use the code as set out in the last "random_both" method. The aim is to return Random names "Ollie" and "Ana" either random(upcase / downcase). The code prints the right answer to the console but doesn't pass all the required tests? Why?
'''
name = "Jordan"
def upper(string)
string.upcase
end
def lower(string)
string.downcase
end
def random_name
["Ollie", "Ana"].sample
end
def random_case(string)
[upper(string), lower(string)].sample
end
def random_both(string)
random_case(random_name)
end
'''
Other methods I attempted that returned JORDAN instead of "Ollie , Ana" are :
'''
def random_both(string)
puts mixm = [random_name + random_case]
end
'''
'''
def random_both(string)
mixm = Proc.new{
y = [upper(string), lower(string)].sample
j = ["Ollie", "Ana"].sample
k = [y, j].sample
}
end
mixm.call
'''
What other simpler solutions could work?
Thank you!
Aucun commentaire:
Enregistrer un commentaire