

JSON.stringify(toDos); //turn to string
const li = event.target.parentElement; //which button is clicked
toDos = toDos.filter((toDo) => toDo.id !== parseInt(li.id)); //exclude the item that return false
const newTodoObj = { //make object(id) instead of text
text:newTodo,
id : Date.now(), //give Random number(id)
}
if(savedToDos !== null) { // if savedToDos exist
const parsedToDos = JSON.parse(savedToDos); // turn to the array
toDos = parsedToDos; //restore previous toDos
parsedToDos.forEach(paintToDo); // paintToDo(function) for Each item
}
'Frontend > Javascript' 카테고리의 다른 글
| 바닐라JS로 크롬앱 만들기(노마드코더) (0) | 2022.01.02 |
|---|---|
| Weather (0) | 2021.12.29 |
| Background (0) | 2021.12.25 |
| Quote (0) | 2021.12.25 |
| Clock (0) | 2021.12.25 |