-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday30.js
44 lines (30 loc) · 872 Bytes
/
day30.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
38
39
40
41
42
43
44
// program to merge and remove duplicate value from an array
function getUniqueAfterMerge(arr1, arr2){
// merge two arrays
let arr = arr1.concat(arr2);
let uniqueArr = [];
// loop through array
for(let i of arr) {
if(uniqueArr.indexOf(i) === -1) {
uniqueArr.push(i);
}
}
console.log(uniqueArr);
}
const array1 = [1, 2, 3];
const array2 = [2, 3, 5]
// calling the function
// passing array argument
getUniqueAfterMerge(array1, array2);
// program to merge and remove duplicate value from an array
function getUniqueAfterMerge(arr1, arr2){
// merge two arrays
let arr = [...arr1, ...arr2];
// removing duplicate
let uniqueArr = [...new Set(arr)];
console.log(uniqueArr);
}
const array1 = [1, 2, 3];
const array2 = [2, 3, 5]
// calling the function
getUniqueAfterMerge(array1, array2);