-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
41 lines (30 loc) · 1.13 KB
/
main.js
File metadata and controls
41 lines (30 loc) · 1.13 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
/*
Function Arrow Challenges
*/
// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]
// Regular Function
let names1 = function (...names) {
// Parameter ?
return `String [${names.join("], [")}] => Done !`;
};
console.log(names1("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !
// Arrow Function
let names2 = (...names) => `String [${names.join("], [")}] => Done !`;
console.log(names2("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !
/* ================================= */
// [1] Replace ??? In Return Statement To Get The Output
// [2] Create The Same Function With Regular Syntax
// [3] Use Array Inside The Arguments To Get The Output
// Arrow Function
let myNumbers = [20, 50, 10, 60];
let calc1 = (one, two, ...nums) => one + two + nums[+false];
console.log(calc1(10, myNumbers[+false], myNumbers[+true])); // 80
// Regular Function
let calc2 = function (one, two, ...nums) {
return one + two + nums[+false];
}
console.log(calc2(10, myNumbers[+false], myNumbers[+true])); // 80