-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
39 lines (36 loc) · 803 Bytes
/
Copy pathcode.js
File metadata and controls
39 lines (36 loc) · 803 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
29
30
31
32
33
34
35
36
37
38
39
// var todoList = ['item 1', 'item 2', 'item 3']
// //to add new
// function addList(add){
// todoList.push(add);
// }
// // to change
// function changeList(tpoic,newContent){
// todoList[topic] = newContent
// }
// //to delete
// function deleteList(topic){
// todoList.splice(topic,1)
// }
// // display list
// function displayList(){
// console.log('Here\'s my' + mytodoList)
// }
//put all functions into a subject
var todoList = {
list: ['item 1','item 2','item 3'],
showList: function(){
console.log(this.list);
},
addList: function(add){
this.list.push(add);
this.showList();
},
changeList: function(item,change){
this.list[item] = change;
this.showList();
},
deleteList: function (item) {
this.list.splice(item,1);
this.showList();
}
}