-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
68 lines (56 loc) · 1.85 KB
/
index.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const inputNumber = document.querySelector<HTMLInputElement>("#inputNumber");
const firstButton = document.querySelector<HTMLButtonElement>("#firstButton");
const secondButton = document.querySelector<HTMLButtonElement>("#secondButton");
const thirdButton = document.querySelector<HTMLButtonElement>("#thirdButton");
const checkButton = document.querySelector<HTMLButtonElement>("#checkButton");
// import {
// inputNumber,
// firstButton,
// secondButton,
// thirdButton,
// checkButton
// } from "./src/importer.js"
const numberList: number[] = [];
const generateRandomNumber = () => {
if (firstButton && inputNumber) {
firstButton.addEventListener("click", () => {
const randomNumber = Math.floor(Math.random() * 90000) + 10000;
inputNumber.value = randomNumber.toString();
const numberValue = parseInt(inputNumber.value);
numberList.push(numberValue);
console.log(numberValue);
});
}
};
const displayNumberList = () => {
if (secondButton) {
secondButton.addEventListener("click", () => {
console.log(numberList);
});
}
};
const clearInput = () => {
if (thirdButton && inputNumber) {
thirdButton.addEventListener("click", () => {
inputNumber.value = "";
});
}
};
const checkBox = () => {
if (checkButton) {
checkButton.addEventListener("click", () => {
for (var i = 0; i < numberList.length; i++) {
var itemType = typeof numberList[i]
if (itemType === "number"){
alert("all items are number.")
} else{
alert("there is an item that it is not number!")
};
};
});
};
};
generateRandomNumber();
displayNumberList();
clearInput();
checkBox();