javascript – Create a class of users


Create a class of users with id, name, age. Write a function to get users over 20 years old. Group all users of the same age and increase the age of users by 3.
Is there a cleaner way of writing this? All comments are appreciated.

const userList =[];
const userAboveTwenty = [];

User class {
constructor (name, id, age) {
this.name = name;
this.id = id;
this.age = age;
}

addUser (user) {
userList.push (user);
}

getUserListAboveTwenty (list) {
userAboveTwenty.push (... list.filter (x => x.age> 20));
}

addAge (user) {
return user.age = user.age + 3;
}
}


let user1 = new User ('user1', 1,12);
let user2 = new User ('user2', 2,18);
leave user3 = new user ('user3', 3,21);
let user4 = new user ('user4', 4,22);

user1.addUser (user1);
user2.addUser (user2);
user3.addUser (user3);
user4.addUser (user4);
user1.addAge (user1);
user1.getUserListAboveTwenty (userList);
user1.addAge (user1);
`` `