Skip to content

Commit ecd157d

Browse files
committed
Sync LeetCode submission Runtime - 52 ms (46.06%), Memory - 49 MB (18.88%)
1 parent 2be9ca3 commit ecd157d

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Write a function&nbsp;<code>createHelloWorld</code>.&nbsp;It should return a new function that always returns&nbsp;<code>&quot;Hello World&quot;</code>.
2+
<p>&nbsp;</p>
3+
<p><strong class="example">Example 1:</strong></p>
4+
5+
<pre>
6+
<strong>Input:</strong> args = []
7+
<strong>Output:</strong> &quot;Hello World&quot;
8+
<strong>Explanation:</strong>
9+
const f = createHelloWorld();
10+
f(); // &quot;Hello World&quot;
11+
12+
The function returned by createHelloWorld should always return &quot;Hello World&quot;.
13+
</pre>
14+
15+
<p><strong class="example">Example 2:</strong></p>
16+
17+
<pre>
18+
<strong>Input:</strong> args = [{},null,42]
19+
<strong>Output:</strong> &quot;Hello World&quot;
20+
<strong>Explanation:</strong>
21+
const f = createHelloWorld();
22+
f({}, null, 42); // &quot;Hello World&quot;
23+
24+
Any arguments could be passed to the function but it should still always return &quot;Hello World&quot;.
25+
</pre>
26+
27+
<p>&nbsp;</p>
28+
<p><strong>Constraints:</strong></p>
29+
30+
<ul>
31+
<li><code>0 &lt;= args.length &lt;= 10</code></li>
32+
</ul>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @return {Function}
3+
*/
4+
var createHelloWorld = function() {
5+
6+
return function(...args) {
7+
return "Hello World"
8+
}
9+
};
10+
11+
/**
12+
* const f = createHelloWorld();
13+
* f(); // "Hello World"
14+
*/

0 commit comments

Comments
 (0)