I have an array of objects with one of the key's being price I am trying to sort the array of objects using .sort()
to sort the objects by price, low to high.
function sortByPrice() {
console.log(window.books)
const sortedArray = window.books.sort((priceA, priceB) => {priceA.price - priceB.price})
return sortedArray
};
I've checked the window.books to make sure that the array is correct and that priceA.price
is a number value