File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- var bestTime = 0 ;
1+ var bestTime = 10 ;
22var start = new Date ( ) . getTime ( ) ;
33
44function getRandomColor ( ) {
@@ -14,13 +14,13 @@ function getRandomColor() {
1414
1515function makeShapeAppear ( ) {
1616
17- var top = Math . random ( ) * 400 ;
17+ var top = Math . random ( ) * 200 ;
1818
1919 var left = Math . random ( ) * 1150 ;
2020
2121 var width = ( Math . random ( ) * 400 ) + 100 ;
2222
23- if ( Math . random ( ) < 0.5 ) {
23+ if ( Math . random ( ) > 0.5 ) {
2424
2525 document . getElementById ( "shape" ) . style . borderRadius = "50%" ;
2626 } else {
@@ -54,19 +54,18 @@ document.getElementById("shape").onclick = function() {
5454
5555 var end = new Date ( ) . getTime ( ) ;
5656
57- var timeTaken = ( end - start ) / 1000 + " sec" ;
57+ var timeTaken = ( end - start ) / 1000 ;
5858
59- document . getElementById ( "timeTaken" ) . innerHTML = timeTaken ;
59+ document . getElementById ( "timeTaken" ) . innerHTML = timeTaken + " sec" ;
6060
61+ if ( timeTaken < bestTime ) {
62+ bestTime = timeTaken ;
63+ document . getElementById ( "best" ) . innerHTML = bestTime + " sec" ;
6164
65+
66+ }
67+
6268
63- if ( timeTaken < bestTime || bestTime == 0 ) {
64- bestTime = timeTaken ;
65- document . getElementById ( "best" ) . innerHTML = bestTime + "s"
66- } else {
67-
68- document . getElementById ( "best" ) . innerHTML = timeTaken + " sec" ;
69- }
7069
7170
7271 Timeout ( ) ;
You can’t perform that action at this time.
0 commit comments