@@ -12,7 +12,7 @@ for (i = 0; i < 5; i++) {
12
12
box . className = "box" ;
13
13
box . style . height = num ;
14
14
box . style . width = num2 ;
15
- var text = document . createTextNode ( n ) ;
15
+ var text = document . createTextNode ( "." ) ;
16
16
text . className = "label" ;
17
17
box . appendChild ( text ) ;
18
18
var arraybox = document . getElementById ( "arraybox" ) ;
@@ -37,7 +37,7 @@ slider.oninput = function() {
37
37
box . className = "box" ;
38
38
box . style . height = num ;
39
39
box . style . width = num2 ;
40
- var text = document . createTextNode ( n ) ;
40
+ var text = document . createTextNode ( "." ) ;
41
41
text . className = "label" ;
42
42
box . appendChild ( text ) ;
43
43
var arraybox = document . getElementById ( "arraybox" ) ;
@@ -91,20 +91,28 @@ async function BubbleSort() {
91
91
for ( i = 0 ; i < lastUnsorted ; i ++ ) {
92
92
a = removePx ( myCollection [ i ] . style . height ) ;
93
93
b = removePx ( myCollection [ i + 1 ] . style . height ) ;
94
-
94
+
95
95
if ( b > a ) {
96
- myCollection [ i ] . style . background = "black" ;
96
+ myCollection [ i ] . style . background = "green" ;
97
+ myCollection [ i ] . style . color = "green" ;
98
+ myCollection [ i + 1 ] . style . background = "red" ;
99
+ myCollection [ i + 1 ] . style . color = "red" ;
97
100
await Swap ( i , i + 1 ) ;
98
101
isSorted = 0 ;
99
- myCollection [ i ] . style . background = "bisque" ;
102
+ myCollection [ i ] . style . background = "bisque" ;
103
+ myCollection [ i ] . style . color = "bisque" ;
104
+ myCollection [ i + 1 ] . style . background = "bisque" ;
105
+ myCollection [ i + 1 ] . style . color = "bisque" ;
100
106
}
101
107
102
108
}
103
109
myCollection [ i ] . style . background = "cyan" ;
110
+ myCollection [ i ] . style . color = "cyan" ;
104
111
lastUnsorted -- ;
105
112
}
106
113
for ( i = 0 ; i < myCollection . length ; i ++ ) {
107
114
myCollection [ i ] . style . background = "cyan" ;
115
+ myCollection [ i ] . style . color = "cyan" ;
108
116
}
109
117
}
110
118
0 commit comments