From bed0e13ceb07a5d9ac8b9b9133f2364e818e6d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Berk=20Ba=C5=9Fo=C4=9Flu?= Date: Thu, 4 Feb 2021 20:06:16 -0500 Subject: [PATCH] Added the Price Sorting. --- scripts/groceries.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/groceries.js b/scripts/groceries.js index b921eae..45e1c7d 100644 --- a/scripts/groceries.js +++ b/scripts/groceries.js @@ -75,6 +75,9 @@ var products = [ } ]; +products.sort(function(a, b) { + return a.price - b.price; +}) // given restrictions provided, make a reduced list of products @@ -122,5 +125,5 @@ function getItemPrice(chosenProduct){ return products[i].price; } } - } +