Remove All Occurrences of a Substring

MediumStringStackSimulation

Solution

export function removeOccurrences(s: string, part: string): string {
  let current = s;
  while (current.indexOf(part) !== -1) {
    current = current.replace(part, '');
  }
  return current;
}