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 vvm70
import assert from "assert";
function removeAllBefore(values: number[], b: number): number[] {
return values.includes(b) ? values.slice(values.indexOf(b)) : values;
}
console.log('Example:');
console.log(removeAllBefore([1, 2, 3, 4, 5], 3));
// These "asserts" are used for self-checking
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!");
June 2, 2020