Skip to content

Commit bc3158a

Browse files
committed
fixed typos and refactored methods
1 parent f4e3adc commit bc3158a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

chapter06/01-Set.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function Set() {
2525
};
2626

2727
this.has = function(value){
28-
return value in items;
28+
return items.hasOwnProperty(value);
29+
//return value in items;
2930
};
3031

3132
this.clear = function(){
@@ -49,8 +50,7 @@ function Set() {
4950
this.sizeLegacy = function(){
5051
var count = 0;
5152
for(var prop in items) {
52-
if(items.hasOwnProperty(prop))
53-
++count;
53+
++count;
5454
}
5555
return count;
5656
};
@@ -93,16 +93,16 @@ function Set() {
9393
};
9494

9595
this.intersection = function(otherSet){
96-
var insertectionSet = new Set(); //{1}
96+
var intersectionSet = new Set(); //{1}
9797

9898
var values = this.values();
9999
for (var i=0; i<values.length; i++){ //{2}
100100
if (otherSet.has(values[i])){ //{3}
101-
insertectionSet.add(values[i]); //{4}
101+
intersectionSet.add(values[i]); //{4}
102102
}
103103
}
104104

105-
return insertectionSet;
105+
return intersectionSet;
106106
};
107107

108108
this.difference = function(otherSet){

0 commit comments

Comments
 (0)