Search⌘ K

Exercise 1: Concatenate Substrings

Practice appending repeated substrings to a given Ruby string by concatenating three occurrences of a specific substring. Learn to manipulate strings and store results effectively, enhancing your understanding of Ruby's built-in string methods.

We'll cover the following...

Problem statement

In the widget below, you’re given a String variable called input_string. Concatenate three occurrences of <3 at the end of this input string. Don’t forget to store the resulting string in result!

Note: Write your code starting at line 4.

Example

input_string = "ruby"
result = "ruby<3<3<3"

Try it yourself

Ruby
def string_producer(input_string)
result = ""
# Start your code here
return result
end