-
Notifications
You must be signed in to change notification settings - Fork 0
/
without.js
37 lines (32 loc) · 995 Bytes
/
without.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// const assertArraysEqual = function (arr, arr2) {
// const happyEmoji = String.fromCodePoint(128512);
// const sadEmoji = String.fromCodePoint(128530);
// if (eqArrays(arr, arr2)) {
// console.log(`${happyEmoji} Assertion Passed: ${arr} === ${arr2}`);
// } else {
// console.log(`${sadEmoji} Assertion Failed: ${arr} !== ${arr2}`);
// }
// }
// const eqArrays = function(arr, arrTwo) {
// if (arr.length !== arrTwo.length) {
// return false;
// }
// for (let i = 0; i < arr.length; i ++) {
// if (arr[i] !== arrTwo[i]) {
// return false;
// }
// }
// return true;
// }
const without = function (source, itemsToRemove) {
let resArr = [];
for (let i = 0; i < source.length; i ++) {
if (!itemsToRemove.includes(source[i])) {
resArr.push(source[i]);
}
}
return resArr;
}
module.exports = without;
// assertArraysEqual(without([1, 2, 3], [1]), [2, 3]);
// assertArraysEqual(without(["1", "2", "3"], [1, 2, "3"]), ["1", "2"]);