why does this show me an error? the problem is with let p = 0;
I just wanted to define the variable and then assign a value to int in the constructor. If i remove that let p = 0;
it works but I don't understand it as I think this.p should refer to a pre-defined variable in the class, right? by the way, I don't know Javascript, my knowledge comes from Java
class Wizard {
let p = 0;
constructor(p) {
this.p = p;
// TODO replace this line.
}
power () {
return this.p;
}
}
let Gandalf = new Wizard(100);