class MoneyManager { constructor(startMoney = null) { this.money = startMoney ?? this.getSavedMoney(); return this.saveMoney(); } saveMoney() { localStorage.setItem('money', String(this.money)); return this.getSavedMoney(); } getSavedMoney() { this.money = Number(localStorage.getItem('money') ?? 0); return this.money; } add(amount = 0) { this.money += amount; return this.saveMoney(); } sub(amount = 0) { this.money -= amount; return this.saveMoney(); } getAmount() { return this.money; } getAmountFormatted() { return Intl.NumberFormat('de-DE', {style: 'currency', currency: 'EUR'}).format(this.money); } }