We're going to see how fast (or slow) you click a button:
First, we'll grab the start time and place it in an object called
startTime
. Right below it, we'll call thealert
function to print out a message soliciting the user to click on the OK button. Right after that, we'll get the ending time and place it into an object calledendTime
.var startTime = $time(); alert('Click on the OK button.'); // The $time() function will be called again as soon as the user presses 'OK' to get the endTime. var endTime = $time();
Next, we need to calculate the difference between
endTime
andstartTime
. Let's place that value inside an object calledtotalTime
.var startTime = $time(); alert('Click on the OK button.'); // The $time() function will be called again as soon as the user //presses "OK" to get the endTime. var endTime = $time(); var totalTime = endTime - startTime;
Finally, we want to print out the results. We'll use the
.write()
JavaScript method to write the results...