Tell us what’s happening:
I have changed clear method to
this.collection = {};
``` but still receive the same result
> The clear method empties the map and the size method returns the number of items present in the map.
**Your code so far**
```js
var Map = function() {
this.collection = {};
// change code below this line
this.add = (key,value) => {
this.collection[key] = value;
}
this.remove = (key) => {
this.collection[key] = undefined;
}
this.get = (key) => {
return this.collection[key];
}
this.has = (key) => {
return this.collection.hasOwnProperty(key);
}
this.values = () => {
return Object.values(this.collection);
}
this.size = () => {
return this.values().length;
}
this.clear = () => {
for(let item of Object.keys(this.collection)) {
delete this.collection[item];
}
}
// change code above this line
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/data-structures/create-a-map-data-structure