Closed ersimont closed 3 years ago
First stab:
function pullAllBy<T>(array: T[], match: (val: T) => boolean): T[] { const pulled: T[] = []; for (let i = 0; i < array.length;) { const val = array[i]; if (match(val)) { array.splice(i, 1); pulled.push(val); } else { ++i; } } return pulled; }
Never mind. remove() is what I actually wanted.
remove()
First stab: