var amount = document.getElementById('timer');
function go(amount) {
var clock = setInterval(function() {
amount = amount - 1;
alert(amount);
}, 1000);
if(amount == 0){
clearInterval(clock);
}
else{
timer.textContent = amount;
}
}
go();