I'm creating a countdown timer and I need to call clearInterval from a different function as I want to start and pause the countdown with two different buttons
Here's a piece of my code
const startCountdown = () => {
    const countdown = setInterval(() => {
      setSecondsElapsed(secondsElapsed => secondsElapsed - 1);
    }, 1000);
  };
  const pauseCountdown = () => {
    clearInterval(countdown);
  };
The countdown starts when I press the initial button but it doesn't pause when I press the button calling pauseCountdown()
 
     
     
    