{"id":10049,"date":"2023-05-07T10:47:56","date_gmt":"2023-05-07T17:47:56","guid":{"rendered":"https:\/\/zxi.mytechroad.com\/blog\/?p=10049"},"modified":"2023-05-07T10:56:27","modified_gmt":"2023-05-07T17:56:27","slug":"leetcode-2667-create-hello-world-function","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/functional\/leetcode-2667-create-hello-world-function\/","title":{"rendered":"\u82b1\u82b1\u9171 LeetCode 2667. Create Hello World Function"},"content":{"rendered":"\n<p>Write a function&nbsp;<code>createHelloWorld<\/code>.&nbsp;It should return a new function that always returns&nbsp;<code>\"Hello World\"<\/code>.<\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> args = []\n<strong>Output:<\/strong> \"Hello World\"\n<strong>Explanation:<\/strong>\nconst f = createHelloWorld();\nf(); \/\/ \"Hello World\"\nThe function returned by createHelloWorld should always return \"Hello World\".\n<\/pre>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> args = [{},null,42]\n<strong>Output:<\/strong> \"Hello World\"\n<strong>Explanation:<\/strong>\nconst f = createHelloWorld();\nf({}, null, 42); \/\/ \"Hello World\"\nAny arguments could be passed to the function but it should still always return \"Hello World\".\n<\/pre>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>0 &lt;= args.length &lt;= 10<\/code><\/li><\/ul>\n\n\n\n<p>Solution: <\/p>\n\n\n\n<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">JavaScript<\/h2>\n<div class=\"tabcontent\">\n\n<pre lang=\"javascript\">\/\/ Author: Huahua\n\/**\n * @return {Function}\n *\/\nvar createHelloWorld = function() {\n    return function(...args) {\n      return \"Hello World\";\n    }\n};\n<\/pre>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Write a function&nbsp;createHelloWorld.&nbsp;It should return a new function that always returns&nbsp;&#8220;Hello World&#8221;. Example 1: Input: args = [] Output: &#8220;Hello World&#8221; Explanation: const f =&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[796],"tags":[222,795,794],"class_list":["post-10049","post","type-post","status-publish","format-standard","hentry","category-functional","tag-easy","tag-functional","tag-javascript","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/10049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=10049"}],"version-history":[{"count":2,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/10049\/revisions"}],"predecessor-version":[{"id":10051,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/10049\/revisions\/10051"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=10049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=10049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=10049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}