Tall-Programacion-FIME / frontend

Repositorio para el frontend del proyecto.
https://fime.uanl.store
0 stars 0 forks source link

Change handle edit book #37

Closed sebastianmarines closed 3 years ago

sebastianmarines commented 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);