|
| 1 | +## [Remove All The Marked Elements of a List](https://www.codewars.com/kata/563089b9b7be03472d00002b/train/javascript) |
| 2 | + |
| 3 | +##### Story |
| 4 | + |
| 5 | +- Define a method/function that removes from a given array of integers all the values contained in a second array. |
| 6 | + |
| 7 | +#### Examples (input -> output): |
| 8 | + |
| 9 | +```js |
| 10 | +* [1, 1, 2, 3, 1, 2, 3, 4], [1, 3] -> [2, 2, 4] |
| 11 | +* [1, 1, 2, 3, 1, 2, 3, 4, 4, 3, 5, 6, 7, 2, 8], [1, 3, 4, 2] -> [5, 6, 7, 8] |
| 12 | +* [8, 2, 7, 2, 3, 4, 6, 5, 4, 4, 1, 2, 3], [2, 4, 3] -> [8, 7, 6, 5, 1] |
| 13 | +``` |
| 14 | + |
| 15 | +##### Notes |
| 16 | + |
| 17 | +- If no button is currently active, return Nothing. |
| 18 | +- If the list is empty, return Nothing. |
| 19 | + |
| 20 | +#### Solution: |
| 21 | + |
| 22 | +```js |
| 23 | +Array.prototype.remove_ = function(integer_list, values_list){ |
| 24 | + return integer_list.filter(item => !values_list.includes(item)); |
| 25 | +} |
| 26 | + |
| 27 | +// Usage |
| 28 | +console.log(removeValues([1, 1, 2, 3, 1, 2, 3, 4], [1, 3])); // [2, 2, 4] |
| 29 | +console.log(removeValues([1, 1, 2, 3, 1, 2, 3, 4, 4, 3, 5, 6, 7, 2, 8], [1, 3, 4, 2])); // [5, 6, 7, 8] |
| 30 | +console.log(removeValues([8, 2, 7, 2, 3, 4, 6, 5, 4, 4, 1, 2, 3], [2, 4, 3])); // [8, 7, 6, 5, 1] |
| 31 | +``` |
0 commit comments