Complete the code to prepend a string to another string.
result = 'world'.[1]('Hello ') puts result
The prepend method adds the given string to the beginning of the original string.
Complete the code to prepend 'Mr. ' to the name variable.
name = 'Smith' name.[1]('Mr. ') puts name
Using prepend adds 'Mr. ' at the start of the string stored in name.
Fix the error in the code to prepend 'Hello, ' to the greeting string.
greeting = 'world' greeting.[1]('Hello, ') puts greeting
The prepend method modifies the string by adding the argument at the start. It returns the modified string, so assignment is optional but allowed.
Fill both blanks to prepend 'Hello, ' and then append '!' to the string.
text = 'world' text.[1]('Hello, ').[2]('!') puts text
First, prepend adds 'Hello, ' at the start. Then, append adds '!' at the end.
Fill all three blanks to prepend 'Hello, ', convert to uppercase, and then append '!' to the string.
text = 'world' text = text.[1]('Hello, ').[2].[3]('!') puts text
First, prepend adds 'Hello, ' at the start. Then upcase converts the whole string to uppercase. Finally, append adds '!' at the end.