Skip to content

Instantly share code, notes, and snippets.

@katio
Last active September 24, 2021 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katio/b77524adce0ca84407511235eab6303a to your computer and use it in GitHub Desktop.
Save katio/b77524adce0ca84407511235eab6303a to your computer and use it in GitHub Desktop.
Totalidad de código de hilo de Twitter #ProgramaciónDesdeCero https://twitter.com/abrupto/status/1411413368091643905
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>
lanzador de dado
</title>
<link rel="icon" type="image/png" href="https://i.imgur.com/dNkJmNs.png">
</head>
<body>
<style>
body {
font-family: Arial;
}
h1 {
color: green;
}
img {
display: block;
}
button {
color: white;
background-color: green;
cursor: pointer;
padding: 10px;
margin: 10px;
}
#dado {
font-size: 85px;
color: green;
}
</style>
<h1> Lanzador de dado </h1>
<img src="https://i.imgur.com/AYxOJot.png" alt="Trébol de 4 hojas">
<button id="boton"> Lanzar dado</button>
<div id="dado">
<script>
function generarNumeroDado() {
return Math.floor(Math.random() * 6) + 1;
}
function lanzarDado() {
dado.innerText = convertirNumeroEnDado(generarNumeroDado());
}
function convertirNumeroEnDado(numero) {
if (numero === 1) {
return '\u{2680}';
} else if (numero === 2) {
return '\u{2681}';
} else if (numero === 3) {
return '\u{2682}';
} else if (numero === 4) {
return '\u{2683}';
} else if (numero === 5) {
return '\u{2684}';
} else if (numero === 6) {
return '\u{2685}';
}
}
boton.addEventListener('click', lanzarDado);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment