Problem 16

Create array from string Recursion Challenge

Given a string, return an array where each element is a single character from the string, in order.

Function Signature

createArray(str)

Parameters

  • str — a string.

Output

Return an array of single-character strings.

Constraints

  • The function must use recursion.
  • The function should accept exactly one argument.

Examples

createArray('hello')    → ['h', 'e', 'l', 'l', 'o']
createArray('hologram') → ['h', 'o', 'l', 'o', 'g', 'r', 'a', 'm']
createArray('i')        → ['i']