TobilobaCodes – LeetCode Explorer

2667. Create Hello World Function

In this page, we will discuss LeetCode Problem 2667: Create Hello World Function. This problem requires you to implement a function that returns the string "Hello World".

📄 Problem Statement

Write a function createHelloWorld. It should return a new function that always returns "Hello World".

💡 Example

Input: const f = createHelloWorld(); f();
Output: "Hello World"

🧠 Explanation

The function createHelloWorld should return a new function that, when called, returns the string "Hello World". This is a simple problem that tests your understanding of function creation and returning functions in JavaScript.

You can implement this using an arrow function or a regular function declaration.

✅ Your Solution


const createHelloWorld = function() {
    return function myFunc(...args) {
        return "Hello World";
    }
};