Closed sebastianmarines closed 3 years ago
Change the way the edit book handler looks for the book that is being edited. Previously it looked for it with a reducer in the books array:
let book = books_for_sale.reduce((acc, curr) => curr.id === book_id ? curr : acc );
This is inefficient because it traverses the whole array even if it already found the book.
The new implementation stops when the book is found:
let book = books_for_sale.find((book) => book.id === book_id);
Change the way the edit book handler looks for the book that is being edited. Previously it looked for it with a reducer in the books array:
This is inefficient because it traverses the whole array even if it already found the book.
The new implementation stops when the book is found: