Skip to content

Commit d84a612

Browse files
add
1 parent 4388ee4 commit d84a612

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

functions/sum/exercise/script.js

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

11-
function add(){
11+
function add(a, b){
1212
//Add function here
13+
return a + b;
1314
}
1415

15-
function sub(){
16+
function sub(a, b){
1617
//Subtract function here
18+
return a-b
1719
}
1820

19-
function div(){
21+
function div(a, b){
2022
//Divide function here
23+
if (b === 0) {
24+
return -1;
25+
}
26+
return a/b
2127
}
2228

23-
function mul(){
29+
function mul(a, b){
2430
//Multiply function here
31+
return a*b
2532
}
2633

2734
console.log('hello from the SUM exercise')
2835
/*
2936
TODO: create a function that console logs the result of any of the above operations.
30-
*/
37+
*/
38+
console.log(div(10,5))

0 commit comments

Comments
 (0)