File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1111 46 , 31 , 57 , 52 , 44 , 18 ,
1212 41 , 53 , 55 , 61 , 51 , 44 ] ;
1313 var output ;
14+ var highScore = 0 ;
15+ var bestSolutions = [ ] ;
1416
17+ // find the highest score
1518 for ( var i = 0 ; i < scores . length ; i ++ ) {
1619 output = "Bubble solution #" + i + " score: " + scores [ i ] ;
1720 console . log ( output ) ;
21+
22+ if ( scores [ i ] > highScore ) {
23+ highScore = scores [ i ] ;
24+ }
25+
26+ }
27+
28+
29+ console . log ( "Quantity Bubbles tests: " + scores . length ) ;
30+ console . log ( "Highest bubble score: " + highScore ) ;
31+
32+ // find the indexes having that highest score
33+ for ( var i = 0 ; i < scores . length ; i ++ ) {
34+ if ( scores [ i ] == highScore ) {
35+ bestSolutions . push ( i ) ;
36+ console . log ( "Solution #" + i + " is a best solution." ) ;
37+ }
1838 }
1939
2040 </ script >
You can’t perform that action at this time.
0 commit comments