0
0
Rubyprogramming~10 mins

String methods (upcase, downcase, strip) in Ruby - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to convert the string to uppercase.

Ruby
text = "hello"
result = text.[1]
Drag options to blanks, or click blank then click option'
Aupcase
Bdowncase
Ccapitalize
Dstrip
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'downcase' instead of 'upcase' changes letters to lowercase.
2fill in blank
medium

Complete the code to remove spaces from the start and end of the string.

Ruby
text = "  hello  "
result = text.[1]
Drag options to blanks, or click blank then click option'
Astrip
Bupcase
Cdowncase
Dchomp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'chomp' removes newline characters, not spaces.
3fill in blank
hard

Fix the error in the code to convert the string to lowercase.

Ruby
text = "HELLO"
result = text.[1]
Drag options to blanks, or click blank then click option'
Acapitalize
Bupcase
Cstrip
Ddowncase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upcase' changes letters to uppercase, which is not what we want here.
4fill in blank
hard

Fill both blanks to convert the string to lowercase and remove spaces.

Ruby
text = "  HeLLo  "
result = text.[1].[2]
Drag options to blanks, or click blank then click option'
Adowncase
Bstrip
Cupcase
Dcapitalize
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order may still work but is less common.
5fill in blank
hard

Fill all three blanks to convert the string to uppercase, remove spaces, and then lowercase it.

Ruby
text = "  HeLLo  "
result = text.[1].[2].[3]
Drag options to blanks, or click blank then click option'
Aupcase
Bstrip
Cdowncase
Dcapitalize
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalize instead of upcase or downcase.