创建映射数据结构
var Map = function() {
this.collection = {};
// change code below this line
this.add = function(key, val){
this.collection[key] = val;
}
this.remove = function(key){
delete this.collection[key];
}
this.get = function(key){
return this.collection[key];
}
this.has = function(key){
return typeof this.collection[key] == 'undefined' ? false : true;
}
this.values = function(){
var val = '';
for(var p in this.collection){
val += this.collection[p];
}
return val;
}
this.clear = function(){
this.collection = {};
}
this.size = function(){
var len = 0;
for(var p in this.collection){
len++;
}
return len;
}
// change code above this line
};