Recall & Review
beginner
What does the
upcase method do to a string in Ruby?The
upcase method converts all the letters in a string to uppercase letters.Click to reveal answer
beginner
How does the
downcase method affect a string?The
downcase method changes all letters in the string to lowercase letters.Click to reveal answer
beginner
What is the purpose of the
strip method in Ruby strings?The
strip method removes any spaces or whitespace characters from the start and end of the string.Click to reveal answer
intermediate
Given the string
" Hello World ", what will strip.upcase return?It will return
"HELLO WORLD". First, strip removes spaces at the start and end, then upcase changes all letters to uppercase.Click to reveal answer
beginner
True or False:
downcase changes numbers and symbols in a string.False.
downcase only changes uppercase letters to lowercase. Numbers and symbols stay the same.Click to reveal answer
What does
"Ruby".upcase return?✗ Incorrect
The
upcase method converts all letters to uppercase, so "Ruby" becomes "RUBY".What will
" space ".strip return?✗ Incorrect
strip removes spaces from both ends, so the result is "space".Which method changes all letters in a string to lowercase?
✗ Incorrect
downcase converts all letters to lowercase.What does
" Hello ".strip.upcase return?✗ Incorrect
First
strip removes spaces, then upcase makes all letters uppercase, resulting in "HELLO".Does
strip remove spaces inside the string?✗ Incorrect
strip only removes spaces and whitespace at the beginning and end, not inside the string.Explain how you can use
upcase, downcase, and strip methods to clean and format a user input string.Think about removing extra spaces and making all letters the same case.
You got /4 concepts.
What happens if you call
strip on a string with no spaces at the start or end?Consider if the string is already clean.
You got /3 concepts.