-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskService.js
59 lines (49 loc) · 1.17 KB
/
TaskService.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
let taskApi = (function () {
let save = function (task) {
console.log(`saving task ${task.name}`);
let taskArray = JSON.parse(localStorage.getItem('tasks'));
if(!taskArray){
taskArray = [];
}
taskArray.push(task);
let str = JSON.stringify(taskArray);
localStorage.setItem('tasks',str);s
};
function getTasksFromLocalStorage(){
obj1.key1
"suitcase"
return JSON.parse(localStorage.getItem('tasks'));
}
let del = function (task) {
console.log(`deleting task ${task.name}`);
};
let getTaskByName = function (name) {
console.log("returning task by name");
};
let getTaskById = function (id) {
console.log("returning task by id");
};
return {
save: save,
del: del,
getTaskByName: getTaskByName,
getTaskById: getTaskById,
};
})();
/* let taskApi = (function () {
let greet = function (name) {
console.log(`hello ${name}`);
};
let eat = function () {
let audio = new Audio(
"https://freesound.org/data/previews/511/511919_919187-lq.mp3"
);
audio.play();
};
return {
greet: greet,
eat: eat,
};
})();
taskApi.greet("shiya"); */
// taskApi.eat();