Skip to content

Commit 352ddaa

Browse files
committed
findMax -> findMaxNumber
1 parent bd69739 commit 352ddaa

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

docs/1-trial-session/10-array/_samples/array-max/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="ja">
33
<head>
44
<meta charset="utf-8" />
5-
<title>findMax関数 解答例 (reduce)</title>
5+
<title>findMaxNumber関数 解答例 (reduce)</title>
66
</head>
77
<body>
88
<script src="./script.js"></script>

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function findMax(numbers) {
1+
function findMaxNumber(numbers) {
22
if (numbers.length === 0) return; // 空配列を除外
33
let maxNumber = numbers[0];
44
for (const number of numbers) {
@@ -14,8 +14,16 @@ const array2 = [-8, -7, -3, -1, -5];
1414
const array3 = [5986, 7202, 9347, 3593, 8166, 662, 2235, 9323, 2240, 943];
1515
const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
1616

17-
document.write(`<p>配列 [${array1}] の最大値は${findMax(array1)} です。</p>`);
18-
document.write(`<p>配列 [${array2}] の最大値は${findMax(array2)} です。</p>`);
19-
document.write(`<p>配列 [${array3}] の最大値は${findMax(array3)} です。</p>`);
20-
document.write(`<p>配列 [${array4}] の最大値は${findMax(array4)} です。</p>`);
21-
document.write(`<p>空の配列の最大値は ${findMax([])} です。</p>`);
17+
document.write(
18+
`<p>配列 [${array1}] の最大値は${findMaxNumber(array1)} です。</p>`,
19+
);
20+
document.write(
21+
`<p>配列 [${array2}] の最大値は${findMaxNumber(array2)} です。</p>`,
22+
);
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.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ document.write(`配列の合計値は: ${sum} です。`);
167167

168168
### 配列の最大値
169169

170-
引数に配列を一つ取り、その配列の最大値を求める関数 `findMax` を作成しましょう。
170+
引数に配列を一つ取り、その配列の最大値を求める関数 `findMaxNumber` を作成しましょう。
171171

172172
:::note
173173

@@ -200,7 +200,7 @@ const array2 = [-8, -7, -3, -1, -5];
200200
const array3 = [5986, 7202, 9347, 3593, 8166, 662, 2235, 9323, 2240, 943];
201201
const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
202202

203-
function findMax(numbers) {
203+
function findMaxNumber(numbers) {
204204
if (numbers.length === 0) return; // 空配列を除外
205205
let maxNumber = numbers[0];
206206
for (const number of numbers) {
@@ -211,11 +211,19 @@ function findMax(numbers) {
211211
return maxNumber;
212212
}
213213

214-
document.write(`<p>配列 [${array1}] の最大値は${findMax(array1)} です。</p>`);
215-
document.write(`<p>配列 [${array2}] の最大値は${findMax(array2)} です。</p>`);
216-
document.write(`<p>配列 [${array3}] の最大値は${findMax(array3)} です。</p>`);
217-
document.write(`<p>配列 [${array4}] の最大値は${findMax(array4)} です。</p>`);
218-
document.write(`<p>空の配列の最大値は ${findMax([])} です。</p>`);
214+
document.write(
215+
`<p>配列 [${array1}] の最大値は${findMaxNumber(array1)} です。</p>`,
216+
);
217+
document.write(
218+
`<p>配列 [${array2}] の最大値は${findMaxNumber(array2)} です。</p>`,
219+
);
220+
document.write(
221+
`<p>配列 [${array3}] の最大値は${findMaxNumber(array3)} です。</p>`,
222+
);
223+
document.write(
224+
`<p>配列 [${array4}] の最大値は${findMaxNumber(array4)} です。</p>`,
225+
);
226+
document.write(`<p>空の配列の最大値は ${findMaxNumber([])} です。</p>`);
219227
```
220228

221229
:::danger

0 commit comments

Comments
 (0)