Challenge 1: Append Hearts

In this challenge you have to create a vector whose every element contains the string "<3" replicated the number of times mentioned in the input vector.

Problem Statement

Implement the function hearts() that takes a vector as input and returns a vector whose each element is a string “<3” replicated the number of times mentioned in the corresponding input vector.

Input

A testVariable containing a vector of numbers.

Output

A vector of strings.

Sample Input

testVariable <- c(5, 2)

Sample Output

"<3<3<3<3<3", "<3<3"

Test Yourself

Write your code in the given area. If you get stuck, you can look at the solution.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy