Skip to content

Instantly share code, notes, and snippets.

@vlazar-
Created January 24, 2023 16:14
Show Gist options
  • Save vlazar-/5c395dd434f1b1967191484e0edcf47d to your computer and use it in GitHub Desktop.
Save vlazar-/5c395dd434f1b1967191484e0edcf47d to your computer and use it in GitHub Desktop.
Slucajni element iz polja
<!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