Accessing Methods Inside Classes in OOP in JavaScript

Some methods can be called inside others via this. Let's look at an example. Let's say we have a class with a user and a method that returns a property:

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

Let's also have a method cape that converts the first letter of a string to capital:

javascriptclass User {
  show() {
    return this.name;
  }
  
  cape(str) {
    return str[0].toUpperCase() + str.slice(1);
  }
}

Let's use the cape method inside the show method:

javascriptclass User {
  show() {
    return this.cape(this.name);
  }
  
  cape(str) {
    return str[0].toUpperCase() + str.slice(1);
  }
}
Задание 1

Make a class Student with properties name and surn.

Задание 2

Create a helper method that will get the first character of the string and capitalize it.

Задание 3

Create a method that will return the student's initials, that is, the first letters of his first and last name.