Stopwatch

Step 4: When the user clicks the start/stop button, one of two things can happen. If the stopwatch is not running, start the stopwatch. But if it is running, stop the stopwatch. Implement this branching by making a Boolean variable and an if/else statement:
let running = false

function startStop() {
  if (running == false) {
    // start stopwatch
  }
  else {
    // stop stopwatch
  }
}
Last step Next step