Find all subsequence combinations of a string

Given a string 'abc', find all distinct subsequence combinations of it.

Hint

Recursively build combinations by adding each character, from the end of the string, to previously generated substrings.

# Python implementation
def combine(s):
  if len(s) == 0:
    return []

  l = combine(s[:-1])

  return l + [x + s[-1] for x in l] + [s[-1]]

s = 'abc'

print(combine(s))
// Javascript implementation
function combine(s) {
  if (s.length === 0) {
    return [];
  }

  const l = combine(s.slice(0, -1));

  return [...l, ...l.map(x => x + s.slice(-1)), s.slice(-1)];
}

const str = 'abc';

console.log(combine(str));