-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstore.js
More file actions
28 lines (22 loc) · 673 Bytes
/
store.js
File metadata and controls
28 lines (22 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(function(global) {
var store = { contacts : [] };
store.ContactInfo = function(name, phone, email) {
return { name : name, phone : phone, email : email }
};
store.addContact = function(contact) {
store.contacts.push(contact);
};
store.removeContact = function(contact) {
for (var i=0; i < store.contacts.length; ++i ) {
if ( store.contacts[i].phone === contact.phone ) {
// found it
store.contacts.splice(i);
break;
}
}
};
store.getContacts = function() {
return store.contacts;
};
global.store = store;
}(this));