-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
99 lines (87 loc) · 2.83 KB
/
main.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var secretSplash = [
"Made by 3prm3!",
"On Github https://github.com/3prm3/calculator!",
"Code peeker!",
"I'm pretty sure this will never be printed!",
"You might want to fork this https://github.com/3prm3/calculator!",
];
var rand = secretSplash[Math.floor(Math.random()*secretSplash.length)];
console.log(rand);
function add() {
var result =
Number(document.getElementById("n1").value) +
Number(document.getElementById("n2").value)+
Number(document.getElementById("n3").value);
document.getElementById("answer").innerHTML =result;
}
function subtract() {
var result =
Number(document.getElementById("n1").value) -
Number(document.getElementById("n2").value) -
Number(document.getElementById("n3").value);
document.getElementById("answer").innerHTML =result
}
function multiply() {
var result =
Number(document.getElementById("n1").value) *
Number(document.getElementById("n2").value)
document.getElementById("answer").innerHTML =result;
}
function division() {
var result =
Number(document.getElementById("n1").value) /
Number(document.getElementById("n2").value)
document.getElementById("answer").innerHTML =result;
}
function modulus() {
var result =
Number(document.getElementById("n1").value) %
Number(document.getElementById("n2").value)
document.getElementById("answer").innerHTML =result;
}
// Partially redundant but here for idiots
function perimSq() {
var result =
Number(document.getElementById("n1").value) *
Number(4);
document.getElementById("answer").innerHTML =result;
}
//#######################################
// Partially redundant but here for idiots
function areaSq() {
var result =
Number(document.getElementById("n1").value) *
Number(document.getElementById("n1").value);
document.getElementById("answer").innerHTML =result;
}
//#######################################
function perimRect() {
var result =
(Number(document.getElementById("n1").value) +
Number(document.getElementById("n2").value))*
Number(2);
document.getElementById("answer").innerHTML =result;
}
// Redundant but here for idiots
function areaRect() {
var result =
Number(document.getElementById("n1").value) *
Number(document.getElementById("n2").value);
document.getElementById("answer").innerHTML =result;
}
//##############################
function areaTri() {
var result =
(Number(document.getElementById("n1").value) *
Number(document.getElementById("n2").value))/
Number(2);
document.getElementById("answer").innerHTML =result;
}
function perimTri() {
var result =
Number(document.getElementById("n1").value) +
Number(document.getElementById("n2").value)+
Number(document.getElementById("n3").value)
Number(2);
document.getElementById("answer").innerHTML =result;
}