Skip to main content
Back to problems
#2667
Easy JavaScript

Create hello world function

82.0% acceptance
Mar 2, 2026
1641
228
Write a function createHelloWorld. It should return a new function that always returns "Hello World".

Solution

TypeScript
Time O(1)
Space O(1)
LeetCode
solution.ts
function createHelloWorld() {
  return function (...args: any[]): string {
  return "Hello World";
  };
}

/**
 * const f = createHelloWorld();
 * f(); // "Hello World"
 */