When vars are replaced with const the code is producing an error. I run this code in the chrome browser console. I tried initializing the variable with let but that is producing an error as well. I ve checked docs on variables before asking this question and I know I am missing something crucial here.
class User {
constructor(email, name){
this.email = email;
this.name = name;
this.score = 0;
}
login(){
console.log(this.email, 'just logged in');
return this;
}
logout(){
console.log(this.email, 'just logged out');
return this;
}
updateScore(){
this.score++;
console.log(this.email, 'score is now', this.score);
return this;
}
}
class Admin extends User {
deleteUser(user){
users = users.filter(u => {
return u.email != user.email
});
}
}
//const userOne = new User ('ryu@ninjas.com', 'Ryu');
var userOne = new User('ryu@ninjas.com', 'Ryu');
var userTwo = new User('yoshi@mariokorp.com', 'Yoshi');
var admin = new Admin('shaun@ninjas.com', 'Shaun');
var users = [userOne, userTwo, admin];
//const users = [userOne, userTwo, admin];
admin.deleteUser(userTwo);
console.log(users);