Balíček karet
karty = ["9♡", "9♣", "7♠", "7♡", "j♠", "8♡", "8♠", "j♣", "a♣", "q♣", "k♢", "8♢", "a♡", "a♠", "q♡", "10♢", "9♠", "a♢", "10♣", "8♣", "j♡", "9♢", "k♡", "7♢", "7♣", "j♢", "k♠", "q♢", "10♠", "q♠", "10♡", "k♣"]
Šablona kompletní
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8" />
<title>Titulek</title>
<style>
/* Vychozi CSS stylovani prijde sem*/
div {margin: 2em 0.3em; border: 1px solid black; padding:0.3em}
/* */
</style>
<script>
/* <![CDATA[ */
/* Sem prijde javascript kod */
//https://javascript.info/task/shuffle
function shuffle(array) {
array.sort(() => Math.random() - 0.5);
}
values = [7,8,9,10,'j','q','k','a']
colors = ['♠','♡','♢','♣']
cards = []
for (let i=0;i<values.length;i++){
for (let j=0;j<colors.length;j++){
cards.push(values[i]+colors[j])
}
}
shuffle(cards)
console.log(cards)
setTimeout(function(){
// tato funkce se spusti az po nacteni stranky
// vypis balicek
document.getElementById("vypis").innerHTML = cards
// zde je misto pro vase experimenty s balickem cards
// vypis znovu
document.getElementById("vypis2").innerHTML = cards
},0)
/* ]]> */
</script>
</head>
<body>
<div id="vypis"></div>
<div id="vypis2"></div>
</body>
</html>
Generování