2809 Create Hello World Function
2809 Create Hello World Function
Create Hello World Function
Write a function createHelloWorld. It should return a new function that always returns ”Hello World”.
Example 1:
1
2
3
4
5
6
7
8
9
**Input:** args = []
**Output:** "Hello World"
**Explanation:**
const f = createHelloWorld();
f(); // "Hello World"
The function returned by createHelloWorld should always return "Hello World".
Example 2:
1
2
3
4
5
6
7
8
9
**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:
1
0 <= args.length <= 10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* @return {Function}
*/
var createHelloWorld = function() {
return function(...args) {
return "Hello World"
}
};
/**
* const f = createHelloWorld();
* f(); // "Hello World"
*/
This post is licensed under CC BY 4.0 by the author.