-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge_array.html
More file actions
80 lines (70 loc) · 1.96 KB
/
Copy pathmerge_array.html
File metadata and controls
80 lines (70 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>Api Screen</h1>
</body>
<script>
let firstArray = [1, 2, 3, 4, 5];
let secondArray = [6, 7, 8, 9, 10, 15];
let thirdArray = [];
// for loop
// for (let i = 0; i < firstArray.length; i++) {
// thirdArray[i] = firstArray[i];
// }
// for (let i = 0; i < secondArray.length; i++) {
// thirdArray[firstArray.length + i] = secondArray[i];
// }
// while loop
let i = 0;
while (i < firstArray.length) {
thirdArray[i] = firstArray[i];
i++;
}
i = 0;
while (i < secondArray.length) {
console.log(thirdArray);
thirdArray[firstArray.length + i] = secondArray[i];
i++;
}
console.log(thirdArray, "Outside of while loop");
let maxNumber = thirdArray[0];
let minNumber = thirdArray[0];
// for (let i = 0; i < thirdArray.length; i++) {
// if (thirdArray[i] > maxNumber) {
// maxNumber = thirdArray[i];
// }
// if (thirdArray[i] < minNumber) {
// minNumber = thirdArray[i];
// }
// }
let j = 1;
// while (j < thirdArray.length) {
// if (thirdArray[j] > maxNumber) {
// maxNumber = thirdArray[j];
// }
// if (thirdArray[j] < minNumber) {
// minNumber = thirdArray[j];
// }
// i++;
// }
// while ((minNumber < maxNumber, (i = thirdArray.length))) {
// minNumber++;
// console.log(minNumber);
// }
console.log(maxNumber);
console.log(minNumber);
let array = [2, 3, 4, 5, 6, 9, 10, 12, 20];
let num = 12;
for (let i = 0; i < array.length; i++) {
if (array[i] === num) {
console.log("yes number is at " + i);
break;
}
}
</script>
</html>