Jump to content

Uzair3D

Members
  • Posts

    2
  • Joined

  • Last visited

Uzair3D's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Please look at the code: in this line: line#42reactionTime = (clickedTime - startTime)/1000; all browsers are saying that startTime is not defined :/ any help will be appreciated <!doctype html><html><head> <title>Learning JavaScript</title> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style type = "text/css"> #simpleBox{ width:200px; height:200px; background-color:red; display:none; } </style></head><body> <div id = "simpleBox"></div> <script type = "text/javascript"> function makeBox() { var clickedTime; var startTime; var reactionTime; var x = Math.random(); x = x*5000; setTimeout(function (){ document.getElementById("simpleBox").style.display = "block"; startTime = Date.now(); }, x); } document.getElementById("simpleBox").onclick = function (){ clickedTime = Date.now(); reactionTime = (clickedTime - startTime)/1000; alert(reactionTime); this.style.display = "none"; makeBox(); } makeBox(); </script></body></html>
×
×
  • Create New...