-
-
Notifications
You must be signed in to change notification settings - Fork 153
LONDON | Gislaine Della Bella | Module-Data-Groups | WEEK 3 | Todo List #225
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?
Conversation
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.
While your method works, it missed using the approach specified in the Instructions section.
- Your code does not use the supplied array 'todos` to store the "todo items"
- You didn't implement
populateTodoList()
- Each todo item does not has the specified HTML
More importantly, you missed the opportunities to apply an approach commonly used in implementing GUI. The approach works in the following way:
- Represent the "application state" using only JS data.
- For this app, the
todos
array would be the application state.
- For this app, the
- Dynamically update the view using HTML and CSS based on the "application state".
- The code inside
populateTodoList()
should, based on the value oftodos
, construct the list items using the API likedocument.createElement()
, and add event listeners to the<i>
elements using.addEventListener()
.
- The code inside
- Whenever you need to mark or unmark an item as completed, change the
completed
property of the corresponding item intodos
. - Whenever you need to add/delete an item, do it in
todos
. - Every time
todos
is modified, callpopulateTodoList()
to update the view.
If you have difficulty figuring out how to implement this, try asking ChatGPT or ask a volunteer.
(Let me know if you want to know what question you can ask ChatGPT to get a sample code)
If you want to store todos
in window.localStorage
as a bonus feature, you can lookup How to store an array of objects in window.localStorage
.
In VSCode, your can right-click in the editor and select "Format Document" to help you indent the code properly. It works for HTML, CSS, and JS. Properly indented code makes code reading easier.
Sprint-3/todo-list/index.html
Outdated
<h2>To-Do-List <img src="assets/icon.png" alt="icon of an arrow"></h2> | ||
<div class="row"> | ||
<input type="text" id="input-box" placeholder="New todo..."> | ||
<button onclick="addTask()" >add</button> |
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.
Instead of using onclick="addTask()"
to assign event listener, you should try using
let theElement = ...; // select the element
theElement.addEventListener("click", () => {
//
});
The latter approach is more flexible, and works also for dynamically created elements.
Hi Cyuan, Now I understand this approach for the populate function is the same as the one we are using for the TV show, and it is much clearer to me now. Thank you! |
I forgt to mention the tip about "format the code "with right click was the best of my day !!!! |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Hello Voluntear,
Here is my code. It is still dificult to write all the function on my onw so I'm trying to undestand the challenges with some tutorials I found on Youtube.
thank you again for your time helping us,
thank you,