JSFiddle - React, Tailwind, and code Playground
by ha ha
HTML
<button id="btn" onclick="randomGo(45, 1)">button</button>
<div id="randomNumber"></div>
CSS
button{
width: 100px;
height: 50px;
background: #336699;
font-size: 14px;
border-radius: 5px;
margin-bottom: 30px;
border: 0;
color: #fff;
}
JavaScript
function randomGo(max, min){
let randomNum = '';
let numArray = [];
let numIndex = 0;
while(numArray.length < 7){
randomNum = Math.floor(Math.random()*(max-min+1))+min;
if(numArray.indexOf(randomNum) == -1){
numArray[numIndex] = randomNum;
numIndex++;
}
}
document.getElementById('randomNumber').innerText = numArray;
}