-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.js
35 lines (27 loc) · 856 Bytes
/
storage.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
function Storage(){
}
Storage.prototype.getTasks = function () {
let gorevler;
if (localStorage.getItem('tasks') === null){
//depo boş
gorevler = [];
console.log("gorevler adında boş bir array döndü");
}else{
gorevler = JSON.parse(localStorage.getItem('tasks'));
}
return gorevler
}
Storage.prototype.addTasks = function(task){
arrays = this.getTasks();
arrays.push(task);
localStorage.setItem('tasks',JSON.stringify(arrays));
}
Storage.prototype.removeTasks = function(textContent){
let array = this.getTasks();
array.forEach(function(element,index) {
if(textContent === element.aciklama){
array.splice(index,1);
}
});
localStorage.setItem("tasks",JSON.stringify(array));
}