Skip to content

Commit 8c7dab8

Browse files
committed
add Task.html for finding the greatest number in an array
1 parent 273b203 commit 8c7dab8

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
8+
<script>
9+
// find the greastest number in the array
10+
let arr = [1, 2, 3, 4, 5];
11+
let greatest = arr[0];
12+
for (let i = 1; i < arr.length; i++) {
13+
if (arr[i] > greatest) {
14+
greatest = arr[i];
15+
}
16+
}
17+
console.log(greatest);
18+
19+
20+
</script>
21+
22+
23+
24+
</head>
25+
<body>
26+
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)