Loading practice questions
What is the output of the given code
print "what's your first name?"
first_name=gets.chomp
a=first_name.capitalize
"first_name.capitalize!".reverse
puts"My name is #{first_name}"
Correct Answer: D — What’s your first name amil
Explanation:
"first_name.capitalize!".reverse reverses the string literal, not the variable. So first_name is unchanged (lowercase). The prompt is printed when code runs.