I get in this line an error: let monatsgebuehr; Code: class Girokonto extends Konto{ let…
- User
I get in this line an error: let monatsgebuehr;
Code: class Girokonto extends Konto{ let monatsgebuehr; constructor(kundenID, typ) { }
setMonatsgebuehr(gebuehr) { this.monatsgebuehr = gebuehr; } getmonatsgebuehr { return this.monatsgebuehr; }}
- Assistant
The error in your code arises because you are trying to declare a class field (
monatsgebuehr) using the keyword directly inside a class, which is not correct syntax in JavaScript. In ES6 (ECMAScript 2015) and later, which introduced the class syntax to Javascript, you should declare class fields without using , , or .