-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrow-functions.js
More file actions
47 lines (38 loc) · 1.07 KB
/
arrow-functions.js
File metadata and controls
47 lines (38 loc) · 1.07 KB
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
45
46
47
/* jshint esversion:6*/
//Usual Functions:
const hello = function () {
const es6 = "ES6";
return `Hello ${es6}`;
};
const powers = [1, 2, 3, 4, 5].map(function (number, index) {
return Math.pow(number, index);
});
const add = function (n1, n2) {
return n1 + n2;
};
const milesToKm = function (miles) {
return miles * 1.60934;
};
console.log(hello());
console.log(powers);
console.log("Addition:", add(100, 100));
console.log("Miles to KM:", milesToKm(100));
console.log("-----------------------------------");
//Arrow function
const user = () => {
const firstName = "Rakib";
const lastName = "Talukder";
return `Hello ${firstName} ${lastName}`;
};
console.log(user());
const sqr = [9, 18, 99, 33, 66].map((number, index) =>
Math.round(Math.sqrt(number, index))
);
console.log(sqr);
const multiply = (n1, n2) => n1 * n2; //remove curly braces if there is only one return statement
console.log(multiply(20, 30));
const temp = (t) => {
let f = t * 1.8 + 32;
return f;
};
console.log("Celsius to Fahrenheit:", temp(50));