如何将teacher类中的grade方法的值转化为大写呀

将teacher类中的grade方法的值转化为大写,并在读取grade是没有信息,输出nograde


```html
class Teacher {
        constructor(options) {
          this.name = options.name;
          this.age = options.age;
          this.course = options.course;
          this.score = options.score;
          this.grade = options.grade;
        }
      }
      const teacher = new Teacher({
        name: "tom",
        age: "30",
        course: "computer safe",
        score: "99",
        grade: "grade one",
      });
      console.log(teacher);

```

es2020版本以上可以这样写,可以看下是不是符合你想要的

img

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="module">
        class Teacher {
            #grade = "";
            constructor(options) {
                this.name = options.name;
                this.age = options.age;
                this.course = options.course;
                this.score = options.score;
                this.#grade = options.grade;
            }

            get grade() {
                if (this.#grade) return this.#grade.toLocaleUpperCase();
                return "nograde"
            }
        }
        const teacher1 = new Teacher({
            name: "tom",
            age: "30",
            course: "computer safe",
            score: "99",
            grade: "grade one",
        });
        const teacher2 = new Teacher({
            name: "tom",
            age: "30",
            course: "computer safe",
            score: "99"
        });
        console.log(teacher1.grade);
        console.log(teacher2.grade);
    </script>
</body>

</html>