diff --git a/code/nathan/javascript/lab05/index.html b/code/nathan/javascript/lab05/index.html new file mode 100644 index 00000000..918ff4b2 --- /dev/null +++ b/code/nathan/javascript/lab05/index.html @@ -0,0 +1,36 @@ + + + + + + + + Lab 05 + + +
+

{{ works }}

+

Todo List

+ + + + + + +

Completed

+ +
+ + + \ No newline at end of file diff --git a/code/nathan/javascript/lab05/script.js b/code/nathan/javascript/lab05/script.js new file mode 100644 index 00000000..81388fdd --- /dev/null +++ b/code/nathan/javascript/lab05/script.js @@ -0,0 +1,48 @@ + +const App = { + data() { + return { + // object + works: 'APP WORKS', + task: '', + completed: false, + todoList: [], + completedList: [] + } + }, + + methods: { + addTodo() { + const newTask = this.task + const todoList = this.todoList + + todoList.push(newTask) + }, + + removeTodo(todo) { + const todoList = this.todoList + const todoIndex = todoList.indexOf(todo) + + todoList.splice(todoIndex, 1) + }, + + completeTodo(todo) { + const todoList = this.todoList + const todoIndex = todoList.indexOf(todo) + const completedList = this.completedList + + completedList.push(todo) + todoList.splice(todoIndex, 1) + }, + + removeCompleted(todo) { + const completedList = this.completedList + const todoIndex = completedList.indexOf(todo) + + completedList.splice(todoIndex, 1) + } + } +} + +const app = Vue.createApp(App) +app.mount('#app') \ No newline at end of file