Added JS functions (+,-,*,/)

This commit is contained in:
NetMan 2024-01-11 23:20:16 +01:00
parent b317efde1d
commit 8f1e927b8b
2 changed files with 34 additions and 1 deletions

View File

@ -8,6 +8,5 @@
<script src="script.js" defer></script>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,34 @@
function add(a, b) {
return a + b;
}
function substract(a, b) {
return a - b;
}
function multiply(a, b) {
return a * b;
}
function divide(a, b) {
return a / b;
}
function operate(equals) {
switch(equals.operator) {
case "+":
return add(equals.a, equals.b);
case "-":
return substract(equals.a, equals.b);
case "*":
return multiply(equals.a, equals.b);
case "/":
return divide(equals.a, equals.b);
}
}
let operation = {
a: 0,
operator: "+",
b: 0,
}