What is your hint or solution suggestion?
Solution
var Map = function() {
this.collection = {};
this.add = (key,value) => {
this.collection[key] = value;
};
this.remove = key => {
if(this.has(key)) {
delete this.collection[key];
}
};
this.get = key => {
return this.collection[key] || null;
};
this.has = key => {
return this.get(key) !== null;
};
this.values = () => {
return Object.values(this.collection);
};
this.size = () => {
return this.values().length;
};
this.clear = () => {
this.collection = {};
};
};
Challenge: Create a Map Data Structure
Link to the challenge: