/stopwatch

a simple stopwatch using object-oriented programming

Primary LanguageJavaScript

stopwatch

a simple stopwatch using object-oriented programming steps:

Design a stopwatch object Members of stopwatch object: duration which is a property. reset, stop and start as methods.

initially the duration is 0. if you start, and then again start, an error will be shown "The stopwatch has already started"

on the other hand, if you stop and then again stop, an error will be shown claiming that "stopwatch is not started yet"

we can access stopwatch duration using sw.duration

use sw.reset() to reset the program and set the duration 0 again