-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.js
More file actions
26 lines (23 loc) · 952 Bytes
/
2.js
File metadata and controls
26 lines (23 loc) · 952 Bytes
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
document.getElementById('num').addEventListener('keyup', () => {
const value = document.getElementById('num').value;
if (value <= 0) {
document.location.reload(true);
}
const result = document.getElementById('inputs');
for (let i = 1; i <= value; i++) {
const input = document.createElement('input');
input.setAttribute('class', 'input-field');
result.appendChild(input);
}
})
const array = [];
document.getElementById('max-min').addEventListener('click', () => {
const value = document.getElementById('num').value;
for (let i = 0; i < value; i++) {
const result = document.getElementsByClassName('input-field')[i].value;
array.push(parseInt(result));
}
const maxNumber = Math.max(...array);
const minNumber = Math.min(...array);
document.getElementById('result').innerHTML = `Maximum number is: ${maxNumber} <br> Minimum number is: ${minNumber}`;
})