-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (27 loc) · 1.26 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function sortearNumero(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
const numeroSorteado = sortearNumero(1, 100);
document.addEventListener('DOMContentLoaded', (event) => {
const numeroDisplay = document.getElementById('result-values');
});
document.querySelector('button').addEventListener('click', () => {
const totalResultados = parseInt(document.querySelectorAll('input')[0].value);
const menorValor = parseInt(document.querySelectorAll('input')[1].value);
const maiorValor = parseInt(document.querySelectorAll('input')[2].value);
const resultValues = document.querySelector('.result-values');
resultValues.innerHTML = '';
for (let i = 0; i < totalResultados; i++) {
const numeroSorteado = sortearNumero(menorValor, maiorValor);
const resultValueDiv = document.createElement('div');
resultValueDiv.className = 'result-value';
resultValueDiv.textContent = numeroSorteado;
resultValues.appendChild(resultValueDiv);
}
let storedResults = JSON.parse(localStorage.getItem('storedResults')) || [];
storedResults.push(numeroSorteado);
localStorage.setItem('storedResults', JSON.stringify(storedResults));
}
);