first commit

This commit is contained in:
2025-01-16 20:38:44 +01:00
commit b60b6dde6d
3 changed files with 82 additions and 0 deletions

37
script.js Normal file
View File

@@ -0,0 +1,37 @@
// Slovenska abeceda
const alphabet = [
'A', 'B', 'C', 'Č', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'V', 'Z', 'Ž'
];
// Funkcija za naključno izbiro črke
function getRandomLetter() {
const randomIndex = Math.floor(Math.random() * alphabet.length);
return alphabet[randomIndex];
}
// Funkcija za zagon odštevalnika
function startTimer() {
let timeLeft = 60; // začetni čas (60 sekund)
const timerElement = document.getElementById('timer');
// Funkcija, ki posodablja preostali čas vsakih 1000 ms (1 sekunda)
const timerInterval = setInterval(function() {
timeLeft--;
timerElement.textContent = `Preostali čas: ${timeLeft}s`;
// Ko čas doseže 0, ustavimo odštevalnik
if (timeLeft <= 0) {
clearInterval(timerInterval);
timerElement.textContent = 'Čas je potekel!';
}
}, 1000);
}
// Prikaz naključne črke na spletni strani
document.getElementById('letter').textContent = getRandomLetter();
// Zaženemo odštevalnik
startTimer();