-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (33 loc) · 840 Bytes
/
script.js
File metadata and controls
42 lines (33 loc) · 840 Bytes
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
/**
function gentagelse(array){
myArray = array;
ingenGentagelser = [];
gamle = [];
for(let i = 0; i < myArray.length; i++){
if (! gamle.includes(myArray[i])){
ingenGentagelser.push(myArray[i]);
gamle.push(myArray[i]);
}
}
console.log(ingenGentagelser);
}
gentagelse([1,2,1,3,1,4]);
**/
ingenGentagelser = [];
gamle = [];
class Gen{
constructor(array){
this.a = array;
}
fjern_gentagelser(){
for(let i = 0; i < this.a.length; i++){
if (! gamle.includes(this.a[i])){
ingenGentagelser.push(this.a[i]);
gamle.push(this.a[i]);
}
}
console.log(ingenGentagelser);
}
}
test = new Gen([1,2,2,1,3,1,4]);
test.fjern_gentagelser();