-
-
Save colevandersWands/1e06ae259f7f8c7eed5500e70d1713a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = { | |
db: {}, | |
next_id: 0, | |
create: function(newThing) { | |
// this.db[this.next_id] = newThing; | |
// this.next_id ++; | |
if(newThing !== ''){ | |
this.db[this.next_id] = newThing; | |
this.next_id ++; | |
console.log("THING WAS ADDED") | |
return 'THING WAS ADDED'; | |
}else{ | |
console.log("ERROR") | |
return 'new value was an empty string, nopes.'; | |
} | |
}, | |
read: function(ID) { | |
if(this.db[ID]){ | |
return this.db[ID]; | |
} else { | |
return 'NOT FOUND'; | |
} | |
}, | |
update: function(ID, new_value) { | |
var returner = ''; | |
// make this work | |
return returner // all good, bad id, bad input or bad id & bad input | |
}, | |
delete: function(ID) { | |
if(this.db[ID]){ | |
this.db[ID] = undefined; | |
console.log('item WAS DELETED'); | |
} else{ | |
console.log('UNKNOWN ID'); | |
} | |
} | |
}; | |
function app_handler() { | |
// read user input from dom | |
var result = app.create(user_input); | |
// write result to dom | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment