Exercise 2: Padding and Justifying

Justify a string by padding it.

Problem statement

There’s a method that allows us to justify a string by paddingpadding it with another string.

Look for that method by skimming through the Ruby documentation for strings. Use it on the input string to accomplish the same task as before.

Example

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

Note: This is a rather unorthodox usage of this method. Normally, we’d use it to align strings to columns so that they line up nicely when we format a table. You’ll use it in exercises later in the course to do just that!

Try it yourself

Press + to interact
def justifying_and_padding(input_string)
result = ""
# Start your code here
return result
end