-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
77 lines (49 loc) · 1.47 KB
/
Copy pathfunctions.js
File metadata and controls
77 lines (49 loc) · 1.47 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
sayHi();
sayHiWithParameter('Duz');
function sayHi() {
console.log('Well, hello there');
}
function sayHiWithParameter(name) {
console.log(`Well, hello there ${name}`);
}
function addThreeNumbers(a, b, c) {
return a + b + c;
}
let result = addThreeNumbers(10, 20, 30);
console.log(result);
function sayHello(firstName, lastName) {
return `Well, hello ${firstName} ${lastName}`;
}
let greeting = sayHello('Billy', 'Moore');
console.log(greeting);
let sayGreeting = function() {
return 'WEll, hello there';
}
console.log(sayGreeting());
// IIFE - Immediately Invoked Function Expression
let sayGreeting2 = (function() {
return 'Hi, how are you';
}());
console.log(sayGreeting2);
let sayGreeting3 = (function(firstName, lastName) {
return `Well, hello there ${firstName} ${lastName};`
}('Billy', 'Moore'));
console.log(sayGreeting3);
console.log(
(function f(n) {
return ((n > 1) ? n * f(n - 1) : n)
})(4)
);
//ES6 fat arrow functions
let speakNames = function(firstName, secondName) {
return `The names are ${firstName} and ${secondName}`;
}
console.log(speakNames('Jack', 'Jill'));
speakNames = (firstName, secondName) => {
return `The names are ${firstName} and ${secondName}`;
}
console.log(speakNames('Duz', 'Goz'));
speakNames = (firstName, secondName) => `The names are ${firstName} and ${secondName}`;
console.log(speakNames('Ekiiks', 'Dum'));
speakNames = firstName => `The names is ${firstName}`;
console.log(speakNames('Nicole'));