-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathproblem.js
More file actions
48 lines (29 loc) · 853 Bytes
/
problem.js
File metadata and controls
48 lines (29 loc) · 853 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
45
46
47
48
/*
Write a function createHelloWorld. It should return a new function that always returns "Hello World".
Example 1:
Input: args = []
Output: "Hello World"
Explanation:
const f = createHelloWorld();
f(); // "Hello World"
The function returned by createHelloWorld should always return "Hello World".
Example 2:
Input: args = [{},null,42]
Output: "Hello World"
Explanation:
const f = createHelloWorld();
f({}, null, 42); // "Hello World"
Any arguments could be passed to the function but it should still always return "Hello World".
Constraints:
0 <= args.length <= 10
*/
/* -------------------Solution---------------------- */
/* @return {Function}
*/
var createHelloWorld = function () {
return function (...args) {
return "Hello World";
}
};
const f = createHelloWorld();
console.log(f());; // "Hello World"