Created
January 24, 2023 16:14
-
-
Save vlazar-/5c395dd434f1b1967191484e0edcf47d to your computer and use it in GitHub Desktop.
Slucajni element iz polja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Sladoled</title> | |
</head> | |
<body> | |
<script> | |
function whoIsBuyingIcecream(names) { | |
let n = names.length; | |
let randomIndex = Math.floor(Math.random() * n); | |
let luckyWinner = names[randomIndex]; | |
return luckyWinner; | |
} | |
let names = ["Vito", "Luka", "Ivano", "Marko", "Slavko"]; | |
console.log(whoIsBuyingIcecream(names) + " nas vodi na sladoled!"); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment