Skip to content

Commit 04a0d75

Browse files
committed
removeMarkedElements
1 parent e8ece5a commit 04a0d75

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

7_kyu/removeMarkedElements.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ Solutions to CodeWars programming tasks. I try to update every day
387387
</tr>
388388
<tr>
389389
<td><a href=" " > </a></td>
390-
<td><a href="7 kyu" > </a></td>
390+
<td><a href="https://github.com/esadakman/javaScript-coding-challenges/blob/master/6_kyu/removeMarkedElements.md" >removeMarkedElements</a></td>
391391
<td><a href="https://github.com/esadakman/javaScript-coding-challenges/blob/master/6_kyu/simpleFrequencySort.md" >simpleFrequencySort</a></td>
392392
<td><a href="5 kyu" > </a></td>
393393
<td><a href="others " ></a></td>

0 commit comments

Comments
 (0)