DEV Community

Discussion on: Daily Challenge #206 - Pound Means Backspace

Collapse
 
empereol profile image
Empereol

TypeScript

function cleanString(input: string): string {
  return [...input].reduce(
    (total, cur) => (cur === '#' ? (total = total.slice(0, -1)) : (total += cur)),
    ''
  );
}