diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md index e0917cf25a..77cd82138f 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md @@ -70,7 +70,41 @@ var Map = function() {
```js -// solution required +var Map = function() { + this.collection = {}; + // change code below this line + + this.add = function(key,value) { + this.collection[key] = value; + } + + this.remove = function(key) { + delete this.collection[key]; + } + + this.get = function(key) { + return this.collection[key]; + } + + this.has = function(key) { + return this.collection.hasOwnProperty(key) + } + + this.values = function() { + return Object.values(this.collection); + } + + this.size = function() { + return Object.keys(this.collection).length; + } + + this.clear = function() { + for(let item of Object.keys(this.collection)) { + delete this.collection[item]; + } + } + // change code above this line +}; ```