From e21ec0cc5bcd35021810adb54bc8202daccbcf68 Mon Sep 17 00:00:00 2001 From: Jesper Date: Wed, 13 Apr 2022 16:35:45 +0200 Subject: [PATCH] Use guard in sellInBelow0 --- TypeScript/app/gilded-rose.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index f34c26a9..e556a2f3 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -52,24 +52,25 @@ export class GildedRose { } private sellInBelow0(item: Item): number { - if (item.sellIn < 0) { - if (item.name == 'Sulfuras, Hand of Ragnaros') return item.quality; + if (item.sellIn >= 0) return item.quality - if (item.name == 'Aged Brie') { - if (item.quality < 50) { - return item.quality + 1 - } - return item.quality - } - - if (item.name == 'Backstage passes to a TAFKAL80ETC concert') { - return 0 - } - - if (item.quality > 0) { - return item.quality - 1 + if (item.name == 'Sulfuras, Hand of Ragnaros') return item.quality; + + if (item.name == 'Aged Brie') { + if (item.quality < 50) { + return item.quality + 1 } + return item.quality } + + if (item.name == 'Backstage passes to a TAFKAL80ETC concert') { + return 0 + } + + if (item.quality > 0) { + return item.quality - 1 + } + return item.quality } }