Skip to content

Commit 54efbf4

Browse files
chvmvdkiyokaanan
andauthored
メソッドの演習と解答例を修正 (#743)
Co-authored-by: kiyokaanan <151308175+kiyokaanan@users.noreply.github.com>
1 parent c4081eb commit 54efbf4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/2-browser-apps/03-class/index.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,16 @@ tanaka.introduceSelf();
111111

112112
### 演習
113113

114-
自分自身の年齢を 1 増やすメソッド `incrementAge` を定義して、実行してみてください
114+
自分自身の年齢を 1 増やすメソッド `incrementAge` を定義して、今年の自己紹介と 1 年後の自己紹介を表示してみてください。田中さんの年齢は好きな値で構いません
115115

116116
<Answer title="年齢を増やすメソッド">
117117

118118
```javascript
119119
class Student {
120120
name;
121-
age = 18;
121+
age;
122122
introduceSelf() {
123-
document.write(`私の名前は${this.name}です。`);
124-
document.write(`${this.age}歳です`);
123+
document.write(`私の名前は${this.name}です。${this.age}歳です。`);
125124
}
126125
incrementAge() {
127126
this.age += 1;
@@ -269,7 +268,7 @@ class FreshmanStudent extends Student {
269268
}
270269
}
271270

272-
const tanaka = new FreshmanStudent("田中", "18", "ドイツ語");
271+
const tanaka = new FreshmanStudent("田中", 18, "ドイツ語");
273272
tanaka.introduceSelf(); // 私の名前は田中です。18歳です。ドイツ語選択です。
274273
```
275274

0 commit comments

Comments
 (0)