Emmanuel Benoist Home Page

Exercise Javascript (somehow Object Oriented)

Javascript Timer class

We have the JavaScript class Date() which has the method getTime().
Create a new JavaScript class called Timer with the following "methods" (or at least functions).:
  • start()
  • stop()
  • lap() returns the elapsed time without stoping the chronometer
  • getTimer() returns the sum of the elapsed time
  • reset() reinitialized the elapsed time to 0

HTML Page

Write a html page containing four buttons:
  • Start
  • Stop
  • Reset
  • Lap
You have also to write a small output: A status of the timer has to be displayed (running / stoped) and the current value of getTimer() (when the timer is stopped) and the current value returned by the last lap() if one was used.