Как остановить таймер с другой функцией JavaScript

Итак, у меня есть этот код

function timer()
{
     setTimeout(function(){alert("Out of time")}, 3000); //Alerts "Out of time" after 3000 milliseconds
}
function resetTime()
{
     timer(); //this is not right, i thought it would override the first function but it just adds another timer as well which is not what I want
}
function stopTime()
{
     //What could go here to stop the first function from fully executing before it hits 3000 milliseconds and displays the alert message?
}

функция timer () запускается при загрузке страницы, но если у меня есть кнопка stopTime (), и я нажимаю на нее, как мне остановить выполнение первой функции и не дать ей попасть в отметку 3000 миллисекунд и выдать предупреждение «Out of time» «?

Ответы на вопрос(1)

Ваш ответ на вопрос