Skip to content

London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Todo List App#1006

Closed
Eugenie-A wants to merge 6 commits intoCodeYourFuture:mainfrom
Eugenie-A:Sprint-3/todo-list
Closed

London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Todo List App#1006
Eugenie-A wants to merge 6 commits intoCodeYourFuture:mainfrom
Eugenie-A:Sprint-3/todo-list

Conversation

@Eugenie-A
Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Added the "Delete completed tasks" button in index.html
  • Implemented deleteCompleted() in todos.mjs
  • Wrote Jest tests for deleteCompleted() in todos.test.mjs
  • Added event listener for delete completed button in script.mjs
  • Implemented deleteCompletedTodos callback in script.mjs

Questions

Why is render without parentheses a bug?

@Eugenie-A Eugenie-A added 🏕 Priority Mandatory This work is expected 🐂 Size Medium 1-4 hours 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Submit:PR Module-Data-Groups The name of the module. Core This is a core task and should be completed by all trainees labels Mar 13, 2026
@kyle-tightest kyle-tightest added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 22, 2026
@@ -1,40 +1,50 @@
<!DOCTYPE html>
<!doctype html>
Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Author

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay no problem

Comment on lines +32 to +35
export function deleteCompleted(todos) {
const completed = todos.filter((todo) => todo.completed);
completed.forEach((todo) => todos.splice(todos.indexOf(todo), 1));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 filter and then iterating over each of the filtered array items when you do forEach.
The .filter method returns an array filtered by the condition you give it.
Try and see if you can use the .filter method differently to achieve the same outcome, without needing forEach?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. I've updated the function to use filter once to get the incomplete todos, then splice to update the original array in place.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this works as well.
But again, when you do splice in that second step you're iterating over each of the filtered array items.
This is not necessary.
Try to look at the function again and see if you can do it in 1 line, instead of 2?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've combined both lines into one, the filter now happens directly inside the splice call so it's done in a single step.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! you can remove the splice and just use filter

Copy link
Copy Markdown
Author

@Eugenie-A Eugenie-A Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I just use filter and return the result, won't the tests fail since they check the original todos array after calling the function?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry you're 100% correct, the function is built to change the array in place instead of returning a new array as a result. Okay nevermind then this is perfect

@kyle-tightest kyle-tightest added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Mar 22, 2026
@Eugenie-A Eugenie-A added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 22, 2026
@kyle-tightest kyle-tightest added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 23, 2026
@Eugenie-A Eugenie-A added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 23, 2026
@kyle-tightest kyle-tightest added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 23, 2026
@Eugenie-A Eugenie-A added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 23, 2026
@kyle-tightest kyle-tightest added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 24, 2026
@illicitonion
Copy link
Copy Markdown
Member

Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Core This is a core task and should be completed by all trainees Module-Data-Groups The name of the module. 🏕 Priority Mandatory This work is expected 🐂 Size Medium 1-4 hours 📅 Sprint 3 Assigned during Sprint 3 of this module Submit:PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants