wrong code!

 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
var x = 4;
var sequence = [-1, -8, 4, 5, -2, 7];
var min = 0;
var max = 0;
var min2 = 0;
var max2 = 0;
for (i = 0; i < sequence.length; i++){
if (sequence[i] < min) {
min = sequence [i];
}
if (sequence[i] > max) {
max = sequence [i];
}
}
console.log (min, max);
for (i = 0; i < sequence.length; i++){
if (sequence[i] < min2 && sequence[i] != min) {
min2 = sequence [i];
}
if (sequence[i] > max2 && sequence[i] != max) {
max = sequence [i];
}
}
console.log (min2, max2);