-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
39 lines (37 loc) · 1.23 KB
/
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>SCUFFED CALCUATOR</h1>
<input id="nrsel" type="text" placeholder="Was yo number">
<h1 id="output"></h1>
<script>
document.getElementById("nrsel").addEventListener("keydown", calc, false)
let nrs = []
function calc (e){
let keyCode = e.keyCode;
if(keyCode==13) {
let inp = document.getElementById("nrsel");
nrs.push(inp.value)
inp.value = '';
inp.placeholder = 'Was yo second number'
} else {
return
}
if(nrs.length == 2){
let one = parseInt(nrs[0]);
let two = parseInt(nrs[1]);
let outpt = one + two;
document.getElementById('output').innerText = outpt;
} else if(nrs.length >= 2){
alert('It appears that adding 2 numbers is my current limit!');
}
}
</script>
</body>
</html>