回答編集履歴

1

例のコードをもう少しわかりやすく修正

2018/04/29 08:54

投稿

YamajiDaisuke
YamajiDaisuke

スコア215

test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  now.setDate(now.getDate() + 1);
16
16
 
17
- console.log(now);
17
+ console.log(now.getDate());
18
18
 
19
19
  ```
20
20
 
@@ -26,7 +26,9 @@
26
26
 
27
27
  now = new Date();
28
28
 
29
- console.log(now.getDate() + (index - 1));
29
+ date = now.getDate() + (index - 1);
30
+
31
+ console.log(date);
30
32
 
31
33
  ```
32
34
 
@@ -38,10 +40,12 @@
38
40
 
39
41
  now = new Date();
40
42
 
41
- console.log(now.setDate(now.getDate() + (index - 1)));
43
+ now.setDate(now.getDate() + (index - 1));
44
+
45
+ console.log(now.getDate());
42
46
 
43
47
  ```
44
48
 
45
49
 
46
50
 
47
- 要するに、nowにsetDateして、nowを出力するのが正解です。
51
+ 要するに、nowにsetDateして、nowを更新してから必要な情報を出力するのが正解です。