DEV Community

Discussion on: Daily Challenge #208 - Delete Occurrences of an Element

Collapse
empereol profile image
Empereol

TypeScript

function deleteNth(lst: number[], n: number): number[] {
  return lst.reduce(
    (arr, cur) => (arr.filter(i => i === cur).length < n ? [...arr, cur] : arr),
    []
  );
}