Repository navigation
Expand file tree
/
Copy pathcallback.js
More file actions
103 lines (71 loc) · 2.01 KB
/
Copy pathcallback.js
File metadata and controls
103 lines (71 loc) · 2.01 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// function repeatLog(n) {
// for (let i = 0; i < n; i += 1) {
// console.log(i);
// }
// }
// repeatLog(5);
// const numbers = [5, 10, 15, 20, 25];
// Класичний for
// for (let i = 0; i < numbers.length; i += 1) {
// console.log(`Індекс ${i}, значення ${numbers[i]}`);
// }
// Метод перебирання forEach
// numbers.forEach(function (number, index) {
// console.log(`Індекс ${index}, значення ${number}`);
// });
// const fnA = function (message, callback) {
// console.log(message)
// console.log(callback)
// callback(100);
// }
// const fnB = function (number) {
// console.log('Log', number)
// }
// fnA('jfgngjn', fnB)
// const doMath = function (a, b, callback) {
// const result = callback(a, b);
// console.log(result);
// }
// doMath(2, 3, function (x, y) {
// return x + y;
// } )
// doMath(2, 3, function (x, y) {
// return x * y;
// } )
// const filter = (array, test) => {
// const filteredArray = [];
// for (const el of array) {
// console.log(el);
// console.log(test(el));
// const passed = test(el)
// if (passed) {
// filteredArray.push(el);
// }
// }
// return filteredArray;
// }
// // const callback1 = value => value >= 3;
// const r1 = filter([1, 2, 3, 4, 5], value => value >= 3);
// console.log(r1);
// const fnA = function (parameter) {
// const innerVariable = 'value of fnA'
// const innerFunction = function () {
// console.log(innerVariable);
// console.log('Its calling innerFunction');
// };
// return innerFunction;
// }
// const fnB = fnA();
// fnB();
// console.log(fnB);
// const add = function (a, b, c) {
// console.log(a, b, c);
// return a + b + c;
// }
// const addArro2 = (a, b, c) => {
// console.log(a, b, c);
// return a + b + c;
// }
// const addArrow = (...args) => console.log(...args);
// console.log(add(5, 10, 15));
// console.log(addArrow(5, 10, 15));