Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // number values -> only price is in lv, everything else is in grams
- const products = [
- {
- type: "Gainer",
- brand: "Physique Nutrition",
- location: "silabg",
- url: "https://www.silabg.com/bg/20968-PHYSIQUE-NUTRITION-Thermo-Gainer.html",
- containerRegularPrice: 118.8,
- containerDiscountedPrice: 92,
- containerTotalWeight: 7250,
- individualServingSize: 180,
- proteinInServing: 50,
- },
- {
- type: "Low-Fat Mozzarella",
- brand: "Own",
- location: "Kaufland|Fantastico|Lidl",
- containerRegularPrice: 2.69,
- containerTotalWeight: 125,
- proteinInServing: 20,
- },
- {
- type: "Bread",
- brand: "Mio 103 Grains",
- location: "T-Market",
- containerRegularPrice: 1.89,
- containerTotalWeight: 350,
- proteinInServing: 12.4,
- },
- {
- type: "Protein Bread",
- brand: "Vita",
- location: "Kaufland|Fantastico|Billa",
- containerRegularPrice: 3.89,
- containerTotalWeight: 400,
- proteinInServing: 21,
- },
- {
- type: "Tuna Fillet in Brine",
- brand: "Own Brand",
- location: "Fantastico",
- containerRegularPrice: 3.69,
- containerTotalWeight: 110,
- proteinInServing: 26.5,
- },
- {
- type: "Lukanka of Horse & Beef",
- brand: "Unitemp",
- location: "Fantastico",
- containerRegularPrice: 7.29,
- containerTotalWeight: 220,
- proteinInServing: 40,
- },
- {
- type: "Pork Pastarma or Fillet Elena",
- brand: "Budget Brand",
- location: "Any Market",
- containerRegularPrice: 8,
- containerDiscountedPrice: 6,
- containerTotalWeight: 200,
- proteinInServing: 38,
- },
- {
- type: "Low-Fat Boiled Pork Ham or Fillet",
- brand: "Budget Brand",
- location: "Any Market",
- containerRegularPrice: 6,
- containerDiscountedPrice: 5,
- containerTotalWeight: 200,
- proteinInServing: 18,
- },
- {
- type: "Boiled Pork Ham",
- brand: "Kazachok",
- location: "Fantastico",
- containerRegularPrice: 6.99,
- containerTotalWeight: 350,
- proteinInServing: 15,
- },
- {
- type: "Eggs Size L",
- brand: "Own Brand",
- location: "Kaufland|Lidl",
- containerRegularPrice: 2.4,
- containerTotalWeight: 240,
- individualServingSize: 60,
- proteinInServing: 6.3,
- },
- {
- type: "Beef Steak",
- brand: "Restaurant's Own Brand",
- location: "Fast-Food Restaurant Shtip-Shtip",
- containerRegularPrice: 16,
- containerTotalWeight: 200,
- proteinInServing: 24,
- },
- {
- type: "Shredded Beef",
- brand: "Restaurant's Own Brand",
- location: "Fast-Food Restaurant Shtip-Shtip",
- containerRegularPrice: 10,
- containerTotalWeight: 200,
- proteinInServing: 24,
- },
- {
- type: "Grilled Chicken Fillet",
- brand: "Restaurant's Own Brand",
- location: "Fast-Food Restaurant Pri Brakyata",
- containerRegularPrice: 5.3,
- containerTotalWeight: 180,
- proteinInServing: 28,
- },
- {
- type: "Grilled Pork Loin",
- brand: "Restaurant's Own Brand",
- location: "Fast-Food Restaurant Pri Brakyata",
- containerRegularPrice: 5.3,
- containerTotalWeight: 180,
- proteinInServing: 26.76,
- },
- {
- type: "Grilled Pork Shoulder Steak",
- brand: "Restaurant's Own Brand",
- location: "Fast-Food Restaurant Pri Brakyata",
- containerRegularPrice: 5.3,
- containerTotalWeight: 180,
- proteinInServing: 25.58,
- },
- {
- type: "Quark",
- brand: "Milbona",
- location: "Lidl",
- containerRegularPrice: 2.69,
- containerTotalWeight: 200,
- proteinInServing: 12.5,
- },
- {
- type: "Quark",
- brand: "Exquisa",
- location: "Kaufland|Fantastico",
- containerRegularPrice: 4.99,
- containerTotalWeight: 400,
- proteinInServing: 10,
- },
- {
- type: "Quark",
- brand: "Danone",
- location: "Kaufland|Fantastico|T-Market",
- containerRegularPrice: 2.19,
- containerTotalWeight: 150,
- proteinInServing: 10,
- },
- {
- type: "Skyr",
- brand: "Exquisa",
- location: "Kaufland|Fantastico",
- containerRegularPrice: 4.99,
- containerTotalWeight: 500,
- proteinInServing: 8.8,
- },
- {
- type: "Protein Bar",
- brand: "Own Brand",
- location: "Lidl",
- containerRegularPrice: 2.49,
- containerTotalWeight: 45,
- individualServingSize: 45,
- proteinInServing: 22.5,
- },
- {
- type: "Protein Bar",
- brand: "Chocolate & Caramel",
- location: "Decathlon",
- containerRegularPrice: 29.90,
- containerTotalWeight: 720,
- individualServingSize: 60,
- proteinInServing: 22,
- },
- {
- type: "Protein Bar",
- brand: "Chocolate & Nuts",
- location: "Decathlon",
- containerRegularPrice: 35.90,
- containerTotalWeight: 720,
- individualServingSize: 60,
- proteinInServing: 22,
- },
- {
- type: "High-Protein Chips",
- brand: "Own Brand",
- location: "Lidl",
- containerRegularPrice: 2.49,
- containerTotalWeight: 40,
- individualServingSize: 40,
- proteinInServing: 20,
- },
- {
- type: "High-Protein Pudding",
- brand: "Milbona",
- location: "Lidl",
- containerRegularPrice: 2.99,
- containerTotalWeight: 200,
- proteinInServing: 10,
- },
- ];
- const bars = [
- {
- type: "Protein Bar",
- brand: "FIT SPO MAXX",
- location: "silabg",
- containerRegularPrice: 42.13,
- containerTotalWeight: 900,
- individualServingSize: 75,
- proteinInServing: 26,
- },
- {
- type: "Protein Bar",
- brand: "FIT SPO Power",
- location: "silabg",
- containerRegularPrice: 31.57,
- containerTotalWeight: 660,
- individualServingSize: 55,
- proteinInServing: 16.5,
- },
- {
- type: "Protein Bar",
- brand: "Bezzo No Sugar",
- location: "silabg",
- containerRegularPrice: 29.57,
- containerTotalWeight: 720,
- individualServingSize: 60,
- proteinInServing: 16.7,
- },
- {
- type: "Protein Bar",
- brand: "Bezzo",
- location: "silabg",
- containerRegularPrice: 36.85,
- containerTotalWeight: 960,
- individualServingSize: 80,
- proteinInServing: 24,
- },
- {
- type: "Protein Bar",
- brand: "Everbuild Crisp",
- location: "silabg",
- containerRegularPrice: 42.24,
- containerTotalWeight: 825,
- individualServingSize: 55,
- proteinInServing: 14.1,
- },
- {
- type: "Protein Bar",
- brand: "Own Brand",
- location: "Lidl",
- containerRegularPrice: 2.49,
- containerTotalWeight: 45,
- individualServingSize: 45,
- proteinInServing: 22.5,
- },
- {
- type: "Protein Bar",
- brand: "Chocolate & Nuts",
- location: "Decathlon",
- containerRegularPrice: 35.90,
- containerTotalWeight: 720,
- individualServingSize: 60,
- proteinInServing: 22,
- },
- ];
- const supplements = [
- {
- type: "Beef Isolate Protein Powder",
- brand: "Everbuild",
- location: "silabg",
- url: "https://www.silabg.com/bg/21858-EVERBUILD-Ultra-Premium-100-Beef-Isolate.html",
- containerRegularPrice: 104.72,
- containerDiscountedPrice: 89,
- containerTotalWeight: 1816,
- individualServingSize: 35,
- proteinInServing: 28,
- },
- {
- type: "Whey Protein Powder",
- brand: "Everbuild",
- location: "silabg",
- url: "https://www.silabg.com/bg/18643-EVERBUILD-Ultra-Premium-Whey-Build.html",
- containerRegularPrice: 118.8,
- containerDiscountedPrice: 101,
- containerTotalWeight: 2271,
- individualServingSize: 34,
- proteinInServing: 24,
- },
- {
- type: "Whey Protein Powder",
- brand: "Optimum Nutrition Gold Standard",
- location: "silabg",
- url: "https://www.silabg.com/bg/176-OPTIMUM-NUTRITION-100-Whey-Gold-Standard.html",
- containerRegularPrice: 138,
- containerTotalWeight: 2272,
- individualServingSize: 30.4,
- proteinInServing: 24,
- },
- {
- type: "Whey Protein Powder",
- brand: "Amix Pure Fusion",
- location: "silabg",
- url: "https://www.silabg.com/bg/11568-AMIX-Whey-Pure-Fusion.html",
- containerRegularPrice: 136.4,
- containerTotalWeight: 2300,
- individualServingSize: 35,
- proteinInServing: 26.25,
- },
- {
- type: "Whey Isolate Protein Powder",
- brand: "Domyos",
- location: "Decathlon",
- url: "https://www.decathlon.bg/p/324917-130370_protein-izolat-whey-22-g-shokolad.html",
- containerRegularPrice: 129,
- containerTotalWeight: 2200,
- individualServingSize: 30,
- proteinInServing: 24,
- },
- {
- type: "Whey Protein Powder",
- brand: "My Protein",
- location: "myprotein",
- url: "https://www.myprotein.bg/sports-nutrition/limited-edition-impact-whey-protein/13470318.html",
- containerRegularPrice: 164.99,
- containerDiscountedPrice: 112,
- containerTotalWeight: 2500,
- individualServingSize: 25,
- proteinInServing: 20.5,
- },
- {
- type: "Whey Protein Powder",
- brand: "Strong Energy",
- location: "stanimiretov",
- url: "https://stanimiretov.com/protein",
- containerRegularPrice: 109,
- containerTotalWeight: 2100,
- individualServingSize: 30,
- proteinInServing: 20,
- },
- {
- type: "Whey Isolate Protein Powder",
- brand: "FA Nutrition Gold",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/3790-14707-fa-nutrition-gold-whey-isolate.html",
- containerRegularPrice: 199.95,
- containerDiscountedPrice: 139.97,
- containerTotalWeight: 2270,
- individualServingSize: 30,
- proteinInServing: 25,
- },
- {
- type: "Whey Hydrolysed Protein Powder",
- brand: "Dorian Yates Nutrition",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/7690-24879-dorian-yates-nutrition-shadowhey-hydrolysate-protein.html",
- containerRegularPrice: 219.95,
- containerDiscountedPrice: 153.97,
- containerTotalWeight: 2270,
- individualServingSize: 25,
- proteinInServing: 22,
- },
- {
- type: "Whey Isolate Protein Powder",
- brand: "Kevin Levrone",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/4178-6934-kevin-levrone-levroiso-whey.html",
- containerRegularPrice: 185.95,
- containerDiscountedPrice: 129.95,
- containerTotalWeight: 2000,
- individualServingSize: 35,
- proteinInServing: 29.8,
- },
- {
- type: "Whey Isolate Protein Powder",
- brand: "FA Nutrition CORE",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/7700-24931-fa-nutrition-core-iso.html",
- containerRegularPrice: 144.95,
- containerDiscountedPrice: 114.51,
- containerTotalWeight: 2000,
- individualServingSize: 30,
- proteinInServing: 25,
- },
- {
- type: "Whey Isolate Protein Powder",
- brand: "Scitec",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/3025-13721-scitec-100-whey-isolate.html",
- containerRegularPrice: 108,
- // containerDiscountedPrice: 108,
- containerTotalWeight: 2000,
- individualServingSize: 25,
- proteinInServing: 19,
- },
- {
- type: "Whey Protein Powder",
- brand: "BSN DNA",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/4265-14962-bsn-dna-whey.html",
- containerRegularPrice: 138,
- containerDiscountedPrice: 78.49,
- containerTotalWeight: 1800,
- individualServingSize: 30,
- proteinInServing: 24,
- },
- {
- type: "Beef Isolate Protein Powder",
- brand: "MuscleTech Platinum",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/4268-14975-muscletech-platinum-beef-protein.html",
- containerRegularPrice: 135,
- containerDiscountedPrice: 98.55,
- containerTotalWeight: 1970,
- individualServingSize: 40,
- proteinInServing: 34,
- },
- {
- type: "Whey Protein Powder",
- brand: "Universal Ultra Pro",
- location: "readyforlife",
- url: "https://readyforlife.bg/asortiment/3170-14002-universal-ultra-whey-pro.html",
- containerRegularPrice: 145,
- containerDiscountedPrice: 123,
- containerTotalWeight: 2268,
- individualServingSize: 30,
- proteinInServing: 22,
- },
- {
- type: "Whey Protein Powder",
- brand: "Sportness",
- location: "dm",
- url: "https://www.dm-drogeriemarkt.bg/sportness-surovatachen-protein-na-prah-s-vkus-na-vanilia-p4058172511110.html",
- containerRegularPrice: 22.4,
- // containerDiscountedPrice: 22.4,
- containerTotalWeight: 450,
- individualServingSize: 100,
- proteinInServing: 80,
- },
- ];
- const regularServingSize = 100;
- const proteinFactor = 10;
- const ranking = bars
- // const ranking = products
- // const ranking = supplements
- .map((item) => {
- const {
- containerRegularPrice,
- containerDiscountedPrice,
- containerTotalWeight,
- individualServingSize,
- proteinInServing,
- } = item;
- const containerPrice = containerDiscountedPrice || containerRegularPrice;
- const servingSize = individualServingSize || regularServingSize;
- const servings = containerTotalWeight / servingSize;
- const containerProteinWeight = servings * proteinInServing;
- item.pricePerTenGrammsOfProtein =
- (containerPrice / containerProteinWeight) * proteinFactor;
- return item;
- })
- .sort((a, b) => a.pricePerTenGrammsOfProtein - b.pricePerTenGrammsOfProtein)
- .map(({ type, brand, location, pricePerTenGrammsOfProtein }, i) => {
- return `${i + 1
- }. ${type} - ${brand}, ${location} -> ${pricePerTenGrammsOfProtein.toFixed(
- 2
- )}lv`;
- })
- .join("\n");
- console.log(
- `Protein sources by price per ${proteinFactor}g of protein: \n${ranking}`
- );
Advertisement
Add Comment
Please, Sign In to add comment