Commit 9c17b848 authored by Rodrigo Diez's avatar Rodrigo Diez

Generador aleatorio

parent ec6c7fa2
......@@ -3,9 +3,45 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="">
<title>Simulacion Loteria</title>
<header class="sticky">
<a href="#" role="button">Home</a>
<a href="#" role="button">About</a>
<a href="#" role="button">Contact</a>
<br />
<div class="container">
<div class="row">
<div class="col-sm">
<div class="col-sm-12 col-md-8 col-lg-6" style="height: calc(100vh - 10.25rem); display: flex; align-items: center; flex: 0 1 auto;">
<legend>Generar numero</legend>
<div class="input-group fluid">
<label for="numero">Numero</label>
<input type="text" value="12345" id="numero" placeholder="Numero">
<div class="input-group fluid">
<a type="button" class="primary" id="generar">Generar</a>
<div class="col-sm">
<p>Copyright &copy; DiezRoFer 2019</p>
<script src="js/script.js"></script>
\ No newline at end of file
* @description Genera una cifra aleatoria del 0 al 9.
function cifraAleatoria(){
return parseInt(Math.random()*9)
* @description Genera un numero aleatrorio de 5 cifras.
function numeroAleatorio(){
let numero = [];
for (i = 0; i < 5; i++){
numero[i] = cifraAleatoria();
return numero;
* @description Genera una String a partir de un numero de 5 cifras
* @param {array} numero Un array con cinco cifras
function numeroToString(numero){
let string = "";
for (i = 0; i < 5; i++){
string += numero[i];
return string;
let generarBTN = document.getElementById("generar");
let numeroINPUT = document.getElementById("numero");
generarBTN.addEventListener("click", ()=>{
let numero = numeroToString(numeroAleatorio());
numeroINPUT.value = numero;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment