-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (37 loc) · 946 Bytes
/
script.js
File metadata and controls
44 lines (37 loc) · 946 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
TODO: Write a function that sums two numbers
TODO: Write a function that subtracts two numbers
TODO: Write a function that divides two numbers.
TODO: Write a function that multiplies two numbers.
*NOTE* be sure to handle dividing by zero 😉
ES5 Syntax: function Add(){}
ES6 Syntax (Arrow function): const add = () => {}
*/
console.log('hello from the Arithmetic exercise')
const add = (a,b) => {
return a + b
}
console.log(`10 + 50 = ${ add(10,50) }`)
const sub = (a,b) => {
return a - b
}
console.log(`10 - 50 = ${ sub(10,50) }`)
const div = (a,b) => {
if (b == 0 || b < 0)
{
console.log("You can't divide by 0 or a negative number");
return undefined;
}
else
{
return a / b;
}
};
console.log(`10 / 50 = ${ div(10,50) }`)
const mul = (a,b) => {
return a * b
}
console.log(`10 * 50 = ${ mul(10,50) }`)
/*
TODO: create a function that console logs the result of any of the above operations.
*/