Declaring Properties Inside Classes in OOP in JavaScript

At the beginning of a class, you can declare what properties this class will have. For example, let's declare that the user will have the property name:

javascriptclass User {
  name;
  
  show() {
    return this.name;
  }
}

You can immediately write some value into it:

javascriptclass User {
  name = 'john';
  
  show() {
    return this.name;
  }
}

Let's now create an object of our class:

javascriptlet user = new User;

Now let's output the initially specified value:

javascriptconsole.log(user.name); // 'john'
Задание 1

Declare properties name and surn in the Student class.

Задание 2

When declaring, add some values ​​to your properties.