Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
remove_all_before solution in Uncategorized category for Remove All Before by Jon_Red
import assert from'assert';
function removeAllBefore(values:number[],b:number):number[]{
return values.slice(Math.max(0,values.indexOf(b)));
}
// self-checks
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]);
July 4, 2020