<p></p>
<button>Pick a random number between 0 and 100 🎲</button>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 1rem;
background: hsl(0, 0%, 96%);
font-family: system-ui, sans-serif;
}
button {
padding: 0.75rem 2rem;
border: 2px solid #111;
background: #fff;
font-family: inherit;
margin-top: 2rem;
cursor: pointer;
background: hsl(0, 0%, 100%);
}
import { random } from "https://cdn.skypack.dev/@georgedoescode/generative-utils@1.0.0";
const btn = document.querySelector("button");
const text = document.querySelector("p");
function generate() {
// min, max, round to a whole number
text.innerHTML = random(0, 100, true);
}
btn.addEventListener("click", () => {
generate();
});
generate();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.