# 2667. Create Hello World Function ###### tags:`Closure` | `leetCode` <font color="#01AE9A" background="E1F3F0">`easy`</font> ### 題目 Write a function createHelloWorld. It should return a new function that always returns "Hello World". ### Example ``` Input: args = [] Output: "Hello World" Explanation: const f = createHelloWorld(); f(); // "Hello World" The function returned by createHelloWorld should always return "Hello World". ``` ### Constraints: - `0 <= args.length <= 10` --- ### 解題邏輯 這題要我們寫一個函示,並且此 a 函式要回傳另一個 b 函式且 b 函式永遠回傳 "Hello World" ```javascript var createHelloWorld = function() { return ()=>"Hello World" }; ``` <!-- {%hackmd @themes/orangeheart %} --> {%hackmd @themes/dracula %}
{"metaMigratedAt":"2023-06-18T03:33:23.973Z","metaMigratedFrom":"Content","title":"2667. Create Hello World Function","breaks":true,"contributors":"[{\"id\":\"da4833e9-8c75-4c4a-9870-e972056b78eb\",\"add\":741,\"del\":58}]"}
Expand menu