Ejercicio4.js 378 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
4. Escribir una función en JavaScript que reciba un id, y ponga en el innerHTML del elemento con el id
referenciado un número aleatorio entre 1 y 100
*/

"use strict";

function aleatorio(identi) {
    let numero = 1 + parseInt(99*Math.random());
    identi.innerHTML = "Numero aleatorio: " + numero;
}

let identi1 = document.getElementById("parrafo");
aleatorio(identi1);