CoursesCSS StudioExamplesGATECompaniesPrepMentora
Programs/JavaScript/Mini Projects

3 / 20

Next
1. Todo List2. Calculator3. Stopwatch4. Countdown Timer5. Quiz App6. Weather App7. Image Carousel8. Modal/Lightbox9. Tabs/Accordion10. Autocomplete Search11. Shopping Cart12. Tic-Tac-Toe13. Snake Game14. Memory Game15. Drag and Drop List16. Form Builder17. Chat Application18. Data Table with Sort/Filter19. Progress Bar20. Infinite Scroll

Mini Projects

  1. 01Todo List
  2. 02Calculator
  3. 03Stopwatch
  4. 04Countdown Timer
  5. 05Quiz App
  6. 06Weather App
  7. 07Image Carousel
  8. 08Modal/Lightbox
  9. 09Tabs/Accordion
  10. 10Autocomplete Search
  11. 11Shopping Cart
  12. 12Tic-Tac-Toe
  13. 13Snake Game
  14. 14Memory Game
  15. 15Drag and Drop List
  16. 16Form Builder
  17. 17Chat Application
  18. 18Data Table with Sort/Filter
  19. 19Progress Bar
  20. 20Infinite Scroll

Stopwatch in JavaScript

Create a stopwatch

BeginnerMini ProjectsExample 3 of 20
stopwatch.js
1class Stopwatch {
2 constructor() { this.startTime = null; this.elapsed = 0; }
3 start() { this.startTime = Date.now() - this.elapsed; }
4 stop() { if(this.startTime) this.elapsed = Date.now() - this.startTime; }
5 reset() { this.elapsed = 0; this.startTime = null; }
6 getTime() { return this.elapsed; }
7}

Output

// Stopwatch functionality

What's going on

Stopwatch measures elapsed time.

PreviousCalculatorNextCountdown Timer

On this page

CodeOutputExplanation
Up nextCountdown Timer
Schoolabe

Learn, Practice, Ace Coding

ExamplesCompaniesTutorialsCSS StudioDSA VisualizersQuizInterview PrepMentoraCareer QuestGATE CS prepGATE CS 2027 study planJob ReadyInternships
AboutContactCareersAffiliate programBlog
DocumentationAPI ReferenceCommunitySupport
Privacy PolicyTermsRefund PolicyCookie Policy

© 2026 Schoolabe