@@ -298,7 +298,7 @@ tanaka.introduceSelf(); // 私の名前は田中です。18歳です。ドイツ
298298
299299` Student ` クラスを継承して ` SeniorStudent ` クラスを作ってみましょう。` SeniorStudent ` クラスのインスタンスは ` researchQuestion ` プロパティを持ち、` introduceSelf ` メソッドを実行すると自分の名前を出力した後に自分の研究内容を紹介するようにしてみましょう。
300300
301- <Answer title = " 学生のClassの定義 " >
301+ <Answer title = " 高学年の学生の自己紹介 " >
302302
303303``` javascript
304304class Student {
@@ -393,50 +393,30 @@ document.write(false.toString()); // false
393393
394394### ` Date ` クラス
395395
396- ドキュメントを読み、[ ` Date ` クラス] ( https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date ) を使って、その日の残り時間を表示してみましょう。
397-
398- 例:
399-
400- 21時25分40秒に実行されたとき、
401-
402- ```
403- 今日は残り2時間34分20秒です。
404- ```
405-
406- と表示する
396+ [ ` Date ` クラス] ( https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date ) を使って、現在時刻を表示してみましょう。` Date ` クラスのドキュメントを読んで、現在時刻を表示するのに必要なメソッドを探してみましょう。
407397
408398:::tip
409399` Date ` クラスには、時間、分、秒などを取得するためのメソッドが定義されています。
410400:::
411401
412- <Answer title = " その日の残り時間" >
413-
414- ` Date#getTime ` メソッドを使います。
402+ <Answer title = " 現在時刻の表示" >
415403
416- ``` js
417- const countdownBox = document .getElementById (" countdown-box " );
404+ ``` javascript
405+ const currentTime = document .getElementById (" current-time " );
418406
419- function getRemainingTime () {
407+ function getCurrentTime () {
420408 const now = new Date ();
421- const endOfDay = new Date (
422- now .getFullYear (),
423- now .getMonth (),
424- now .getDate (),
425- 23 ,
426- 59 ,
427- 59 ,
428- 999 ,
429- );
430- const remainingTime = endOfDay .getTime () - now .getTime ();
431-
432- const hours = Math .floor (remainingTime / (1000 * 60 * 60 ));
433- const minutes = Math .floor (remainingTime / (1000 * 60 )) % 60 ;
434- const seconds = Math .floor (remainingTime / 1000 ) % 60 ;
435-
436- return ` 今日の残り時間: ${ hours} 時間 ${ minutes} 分 ${ seconds} 秒です。` ;
409+ const currentYear = now .getFullYear ();
410+ const currentMonth = now .getMonth () + 1 ;
411+ const currentDate = now .getDate ();
412+ const currentHour = now .getHours ();
413+ const currentMinute = now .getMinutes ();
414+ const currentSecond = now .getSeconds ();
415+
416+ return ` 今は${ currentYear} 年${ currentMonth} 月${ currentDate} 日${ currentHour} 時${ currentMinute} 分${ currentSecond} 秒です。` ;
437417}
438418
439- countdownBox .textContent = getRemainingTime ();
419+ currentTime .textContent = getCurrentTime ();
440420```
441421
442422<ViewSource url = { import .meta .url } path = " _samples/count-down" />
@@ -451,7 +431,7 @@ countdownBox.textContent = getRemainingTime();
451431
452432<Answer title = " 図形クラス" >
453433
454- ``` js
434+ ``` javascript
455435class Shape {
456436 color;
457437 constructor (color ) {
0 commit comments