Skip to content

Commit 72bc9f7

Browse files
committed
Update sample scripts in array
1 parent 47302e1 commit 72bc9f7

File tree

1 file changed

+5
-5
lines changed
  • docs/1-trial-session/10-array/_samples/array-max

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
const array1 = [3, 6, 8, 5, 0];
2+
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];
5+
16
function findMaxNumber(numbers) {
27
if (numbers.length === 0) return; // 空配列を除外
38
let maxNumber = numbers[0];
@@ -9,11 +14,6 @@ function findMaxNumber(numbers) {
914
return maxNumber;
1015
}
1116

12-
const array1 = [3, 6, 8, 5, 0];
13-
const array2 = [-8, -7, -3, -1, -5];
14-
const array3 = [5986, 7202, 9347, 3593, 8166, 662, 2235, 9323, 2240, 943];
15-
const array4 = [-878, -40, -324, -410, -592, -610, -880, -65, -423, -32];
16-
1717
document.write(
1818
`<p>配列 [${array1}] の最大値は${findMaxNumber(array1)} です。</p>`,
1919
);

0 commit comments

Comments
 (0)