Skip to content

Commit e0a8464

Browse files
committed
hellofun
1 parent 06c3e1b commit e0a8464

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Programs/Exercise/hellofun.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
3+
Write a function createHelloWorld.
4+
It should return a new function that always returns
5+
"Hello World".
6+
7+
8+
Example 1:
9+
10+
Input: args = []
11+
Output: "Hello World"
12+
Explanation:
13+
const f = createHelloWorld();
14+
f(); // "Hello World"
15+
*/
16+
17+
var createHelloWorld = function() {
18+
19+
return function(...args) {
20+
21+
return "Hello World"
22+
23+
}
24+
};
25+
26+
console.log(createHelloWorld()()); // Hello World

0 commit comments

Comments
 (0)