-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathass6.html
More file actions
29 lines (22 loc) · 757 Bytes
/
ass6.html
File metadata and controls
29 lines (22 loc) · 757 Bytes
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
<!DOCTYPE html>
<html>
<head></head>
<body>
<script>
function createCalculator() {
return {
add: (a, b) => a + b,
subtract: (a, b) => a - b,
multiply: (a, b) => a * b,
divide: (a, b) => b !== 0 ? a / b : "Cannot divide by zero"
};
}
const calc = createCalculator();
console.log(calc.add(5, 3));
console.log(calc.subtract(10, 4));
console.log(calc.multiply(2, 3));
console.log(calc.divide(8, 4));
console.log(calc.divide(8, 2));
</script>
</body>
</html>