# 2667. Create Hello World Function ###### tags: `leetcode 30 days js challenge` `Easy` [2667. Create Hello World Function](https://leetcode.com/problems/create-hello-world-function/) ### 題目描述 Write a function `createHelloWorld`. It should return a new function that always returns `"Hello World"`. ### 範例 **Example 1:** ``` Input: args = [] Output: "Hello World" Explanation: const f = createHelloWorld(); f(); // "Hello World" The function returned by createHelloWorld should always return "Hello World". ``` **Example 2:** ``` 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**: - `0 <= args.length <= 10` ### 解答 #### TypeScript ```typescript= function createHelloWorld() { return function (...args: any[]): string { return 'Hello World'; }; } ``` > 友善第一天,~~希望就維持這難度了~~ > [name=Sheep][time=Fri, May 5, 2023] ### Reference [回到題目列表](https://hackmd.io/@Marsgoat/leetcode_every_day)