From e667c5d091ec7e5e94103b65df03b011c9c077be Mon Sep 17 00:00:00 2001 From: Jesper Date: Wed, 13 Apr 2022 16:36:36 +0200 Subject: [PATCH] Destructure item --- TypeScript/app/gilded-rose.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index e556a2f3..691af995 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -51,26 +51,26 @@ export class GildedRose { return this.items; } - private sellInBelow0(item: Item): number { - if (item.sellIn >= 0) return item.quality + private sellInBelow0({quality, name, sellIn}: Item): number { + if (sellIn >= 0) return quality - if (item.name == 'Sulfuras, Hand of Ragnaros') return item.quality; + if (name == 'Sulfuras, Hand of Ragnaros') return quality; - if (item.name == 'Aged Brie') { - if (item.quality < 50) { - return item.quality + 1 + if (name == 'Aged Brie') { + if (quality < 50) { + return quality + 1 } - return item.quality + return quality } - if (item.name == 'Backstage passes to a TAFKAL80ETC concert') { + if (name == 'Backstage passes to a TAFKAL80ETC concert') { return 0 } - if (item.quality > 0) { - return item.quality - 1 + if (quality > 0) { + return quality - 1 } - return item.quality + return quality } }