first commit
This commit is contained in:
37
script.js
Normal file
37
script.js
Normal 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();
|
||||
|
||||
Reference in New Issue
Block a user