Hi everybody, why my code have typeError? I could not understand. Thanks for helping
function Dictionary(){
this.add = add;
this.datastore = new Array();
this.find = find;
this.remove = remove;
this.showAll = showAll;
}
function add(key, value){
this.datastore[key] = value;
}
function find(key){
return this.datastore[key];
}
function remove(key){
delete this.datastore[key];
}
function showAll() {
Object.keys(this.datastore).forEach( function(key, index) {
console.log(key + "->" + this.datastore[key]);
});
}
var pbook = new Dictionary();
pbook.add("Mike", "123");
pbook.add("David", "345");
pbook.add("Cynhia", "456");
console.log("David's extension: " + pbook.find("David"));
pbook.remove("David");
pbook.showAll();