-
-
Notifications
You must be signed in to change notification settings - Fork 270
London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Todo List App #1006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e06dff0
c173e8b
8c60f9d
cc75d04
cea3408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,50 @@ | ||
| <!DOCTYPE html> | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
| <title>ToDo List</title> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>ToDo List</title> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <link | ||
| href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" | ||
| rel="stylesheet" | ||
| /> | ||
|
|
||
| <script type="module" src="script.mjs"></script> | ||
| </head> | ||
| <body> | ||
| <div class="todo-container"> | ||
| <h1>My ToDo List</h1> | ||
| <script type="module" src="script.mjs"></script> | ||
| </head> | ||
| <body> | ||
| <div class="todo-container"> | ||
| <h1>My ToDo List</h1> | ||
|
|
||
| <div class="todo-input"> | ||
| <input type="text" id="new-task-input" placeholder="Enter a new task..." /> | ||
| <button id="add-task-btn">Add</button> | ||
| </div> | ||
|
|
||
| <ul id="todo-list" class="todo-list"> | ||
| </ul> | ||
| <div class="todo-input"> | ||
| <input | ||
| type="text" | ||
| id="new-task-input" | ||
| placeholder="Enter a new task..." | ||
| /> | ||
| <button id="add-task-btn">Add</button> | ||
| </div> | ||
|
|
||
| <!-- | ||
| <ul id="todo-list" class="todo-list"></ul> | ||
| <button id="delete-completed-btn">Delete completed tasks</button> | ||
| <!-- | ||
| This is a template for the To-do list item. | ||
| It can simplify the creation of list item node in JS script. | ||
| --> | ||
| <template id="todo-item-template"> | ||
| <li class="todo-item"> <!-- include class "completed" if the task completed state is true --> | ||
| <span class="description">Task description</span> | ||
| <div class="actions"> | ||
| <button class="complete-btn"><span class="fa-solid fa-check" aria-hidden="true"></span></button> | ||
| <button class="delete-btn"><span class="fa-solid fa-trash" aria-hidden="true"></span></button> | ||
| </div> | ||
| </li> | ||
| </template> | ||
|
|
||
| </div> | ||
| </body> | ||
| <template id="todo-item-template"> | ||
| <li class="todo-item"> | ||
| <!-- include class "completed" if the task completed state is true --> | ||
| <span class="description">Task description</span> | ||
| <div class="actions"> | ||
| <button class="complete-btn"> | ||
| <span class="fa-solid fa-check" aria-hidden="true"></span> | ||
| </button> | ||
| <button class="delete-btn"> | ||
| <span class="fa-solid fa-trash" aria-hidden="true"></span> | ||
| </button> | ||
| </div> | ||
| </li> | ||
| </template> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,10 @@ export function toggleCompletedOnTask(todos, taskIndex) { | |
| if (todos[taskIndex]) { | ||
| todos[taskIndex].completed = !todos[taskIndex].completed; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Filter out all the completed tasks and update the original array in place | ||
| export function deleteCompleted(todos) { | ||
| const incomplete = todos.filter((todo) => !todo.completed); | ||
| todos.splice(0, todos.length, ...incomplete); | ||
| } | ||
|
Comment on lines
+32
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this code works, it is inefficient as you are iterating over the entire array when you do
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the feedback. I've updated the function to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this works as well. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not case sensitive so it doesn't matter but it is more standard to capitalise this.
did your formatter do this automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my Prettier formatter in VS Code doing it automatically on save. I know it's more standard to keep it uppercase but Prettier lowercases it by default. Prettier formatter is the standard formatter we were asked to use in our work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay no problem