-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
50 lines (39 loc) · 985 Bytes
/
index.html
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
<!Doctype Html>
<html>
<head>
<title>Hello</title>
<style>
body{
background-color: #96b2d7;
height: 100vw;
font-size: 1.5em;
width: 100%;
}
</style>
</head>
<body>
Enter desired number length:
<input id="userInput">
<button id = "generateButton">Generate</button>
<div id ="display">
</div>
</body>
<script>
var display = document.getElementById("display");
var userInput = document.getElementById("userInput");
document.getElementById("generateButton").onclick = function(){
display.innerHTML = randomNumber(userInput.value);
if(display.innerHTML == ""){
alert("Opps thats not a number");
}
userInput.value = "";
}
function randomNumber(length){
let number = "";
for(let i =0 ;i < length; i++){
number += Math.round(Math.random() * 9);
}
return number;
}
</script>
</html>