With the first button I want to stop the interval and in the second part to continue the interval, I thought that from where I stayed the increase could continue later ... And now not even stop the first interval
<!DOCTYPE html>
<html lang="es">
<head>
<title>Objeto Window</title>
<meta charset="UTF8"/>
<body>
<p>El intervalo que sucede cada 1.000 milisegundos se ha repetido <span id="tiempo">0</span> veces.</p>
<button onclick="pararIntervalo()">Parar el intervalo</button>
<button onclick="continuarIntervalo()">continuar el intervalo</button>
</body>
<script>
let miIntervalo = setInterval(
function(){
miTemporizador()
},1000);
let incremento = 0;
function miTemporizador() {
incremento++;
document.getElementById("tiempo").innerHTML = incremento;
}
function pararIntervalo() {
clearInterval(miIntervalo);
}
let miIntervalo2 = setInterval(
function(){
continuarIntervalo()
},1000);
function continuarIntervalo() {
incremento++;
document.getElementById("tiempo").innerHTML = incremento;
}
</script>
</head>
</html>