Skip to content

Commit 6bc3a14

Browse files
committed
Functions/sum
1 parent 4388ee4 commit 6bc3a14

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

functions/sum/exercise/index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
</head>
1010

1111
<body>
12-
<script src="script.js"></script>
13-
</body>
14-
15-
</html>
16-
17-
18-
19-
<!-- <form onsubmit="summarize()">
12+
<form onsubmit="summarize()">
2013
<label for="a">Input #1:</label><input type="text" name='a' id='a'/>
2114
<br>
2215
<label for="b">Input #2:</label><input type="text" name='b' id='b'/>
2316

2417
<button type="submit">Submit</button>
2518
</form>
2619

27-
<div id="summary"> </div> -->
20+
<div id="summary"> </div>
21+
<script src="script.js"></script>
22+
</body>
23+
24+
</html>
25+
26+
27+

functions/sum/exercise/script.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,44 @@
88
ES6 Syntax (Arrow function): const add = () => {}
99
*/
1010

11-
function add(){
12-
//Add function here
13-
}
11+
// // function add(a,b){
12+
// // //Add function here
13+
// // return a + b;
14+
// // }
15+
// console.log(add(2,2))
1416

15-
function sub(){
16-
//Subtract function here
17-
}
17+
// function sub(a, b){
18+
// //Subtract function here
19+
// return a - b;
20+
// }
21+
// console.log(sub(2,2));
1822

19-
function div(){
20-
//Divide function here
21-
}
23+
// function div(a, b){
24+
// //Divide function here
25+
// return a / b;
26+
// }
27+
// console.log(div(2,2));
2228

23-
function mul(){
24-
//Multiply function here
25-
}
29+
// function mul(a, b){
30+
// //Multiply function here
31+
// return a * b;
32+
// }
33+
// console.log(mul(2,2));
2634

35+
36+
//ES6 Arrow functions
37+
38+
const add = (a,b) => a + b;
39+
console.log(add(2,2));
40+
41+
const sub= (a, b) => a - b;
42+
console.log(sub(2, 2));
43+
44+
const div = (a, b) => a / b;
45+
console.log(div(2, 2));
46+
47+
const mul = (a, b) => a * b;
48+
console.log(mul(2, 2))
2749
console.log('hello from the SUM exercise')
2850
/*
2951
TODO: create a function that console logs the result of any of the above operations.

0 commit comments

Comments
 (0)