Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
A very unique solution solution in Creative category for Remove All Before by danielsan
function removeAllBefore (values: number[], b: number, io: number = ~values.indexOf(b)): number[] {
return values.slice(io && ~io)
}
console.log('Example:');
console.log(removeAllBefore([1, 2, 3, 4, 5], 3));
import assert from "assert";
assert.deepEqual(removeAllBefore([1, 2, 3, 4, 5], 3), [3, 4, 5]);
assert.deepEqual(removeAllBefore([1, 1, 2, 2, 3, 3], 2), [2, 2, 3, 3]);
assert.deepEqual(removeAllBefore([1, 1, 2, 4, 2, 3, 4], 2), [2, 4, 2, 3, 4]);
assert.deepEqual(removeAllBefore([1, 1, 5, 6, 7], 2), [1, 1, 5, 6, 7]);
assert.deepEqual(removeAllBefore([], 0), []);
assert.deepEqual(removeAllBefore([7, 7, 7, 7, 7, 7, 7, 7, 7], 7), [7, 7, 7, 7, 7, 7, 7, 7, 7]);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
April 23, 2020
Comments: