Skip to content

Commit 463f9e7

Browse files
authored
Delete unnecessary commentout (#669)
* Delete unnecessary test code * Update index.mdx
1 parent b6b5b21 commit 463f9e7

File tree

2 files changed

+0
-58
lines changed

2 files changed

+0
-58
lines changed

docs/1-trial-session/10-array/_samples/array-max/script.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const array1 = [3, 6, 8, 5, 0];
22
const array2 = [-8, -7, -3, -1, -5];
3-
const array3 = [5986, 7202, 9347, 3593, 8166, 662, 2235, 9323, 2240, 943];
4-
const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
53

64
function findMaxNumber(numbers) {
75
if (numbers.length === 0) return; // 空配列を除外
@@ -20,10 +18,3 @@ document.write(
2018
document.write(
2119
`<p>配列 [${array2}] の最大値は${findMaxNumber(array2)} です。</p>`,
2220
);
23-
document.write(
24-
`<p>配列 [${array3}] の最大値は${findMaxNumber(array3)} です。</p>`,
25-
);
26-
document.write(
27-
`<p>配列 [${array4}] の最大値は${findMaxNumber(array4)} です。</p>`,
28-
);
29-
document.write(`<p>空の配列の最大値は ${findMaxNumber([])} です。</p>`);

docs/1-trial-session/10-array/index.mdx

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ document.write(studentNames); // 田中,佐藤,鈴木,内藤
118118
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
119119
```
120120

121-
```javascript
122-
const numbers = [-3, -1, 9, -10, 3, 7, 6, 1, 0, 5];
123-
```
124-
125121
:::
126122

127123
<Answer title="配列の要素の和">
@@ -171,8 +167,6 @@ document.write(`配列の合計値は ${sum} です。`);
171167
```javascript
172168
const array1 = [3, 6, 8, 5, 0];
173169
const array2 = [-8, -7, -3, -1, -5];
174-
const array3 = [5986, 7202, 9347, 3593, 8166, 662, 2235, 9323, 2240, 943];
175-
const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
176170
```
177171

178172
:::
@@ -192,8 +186,6 @@ const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
192186
```javascript
193187
const array1 = [3, 6, 8, 5, 0];
194188
const array2 = [-8, -7, -3, -1, -5];
195-
const array3 = [5986, 7202, 9347, 3593, 8166, 662, 2235, 9323, 2240, 943];
196-
const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
197189

198190
function findMaxNumber(numbers) {
199191
if (numbers.length === 0) return; // 空配列を除外
@@ -212,13 +204,6 @@ document.write(
212204
document.write(
213205
`<p>配列 [${array2}] の最大値は${findMaxNumber(array2)} です。</p>`,
214206
);
215-
document.write(
216-
`<p>配列 [${array3}] の最大値は${findMaxNumber(array3)} です。</p>`,
217-
);
218-
document.write(
219-
`<p>配列 [${array4}] の最大値は${findMaxNumber(array4)} です。</p>`,
220-
);
221-
document.write(`<p>空の配列の最大値は ${findMaxNumber([])} です。</p>`);
222207
```
223208

224209
:::danger
@@ -228,37 +213,3 @@ document.write(`<p>空の配列の最大値は ${findMaxNumber([])} です。</p
228213
<ViewSource url={import.meta.url} path="_samples/array-max" />
229214

230215
</Answer>
231-
232-
{/* prettier-ignore */}
233-
{/* オブジェクトはまだ扱っていないためコメントアウト
234-
235-
## 配列とオブジェクト
236-
237-
配列はオブジェクトの一種です。しかしながら、JavaScript のオブジェクトとは、[オブジェクトの節](/docs/trial-session/object/)で扱ったように、プロパティ名とプロパティ値の組み合わせでした。
238-
239-
配列もこの原則に従って動作しています。次の図に示すように、配列とは、各要素のインデックスがプロパティ名になっているオブジェクトだと考えることができるのです。
240-
241-
![配列のプロパティ](./array-properties.png)
242-
243-
逆に、その他のオブジェクトも配列と同じように使用することができます。この記法を**ブラケット記法**と呼び、プログラムの動作に応じて使用したいプロパティを切り替えるのに役立ちます。
244-
245-
```javascript
246-
const subject = "math"; // ここを変えると表示される教科が変わる
247-
const scores = { math: 90, science: 80 };
248-
document.write(`${subject} の点数は ${scores[subject]} です。`); // math の点数は 90 です。
249-
```
250-
251-
:::tip[オブジェクトのプロパティ]
252-
253-
オブジェクトのプロパティに数値は使用できません。それではなぜ、配列の場合は `studentNames[2]` のように記述できるのでしょうか。
254-
255-
答えは単純で、文字列に変換されているからです。このため、次のプログラムは全く問題なく動作します。
256-
257-
```javascript
258-
const studentNames = ["田中", "佐藤", "鈴木"];
259-
document.write(studentNames["0"]); // 田中
260-
```
261-
262-
:::
263-
264-
\*/}

0 commit comments

Comments
 (0)