2023-05-15 17:43:00 +08:00
{
"data" : {
"question" : {
"questionId" : "2809" ,
"questionFrontendId" : "2667" ,
"categoryTitle" : "JavaScript" ,
"boundTopicId" : 2255550 ,
"title" : "Create Hello World Function" ,
"titleSlug" : "create-hello-world-function" ,
"content" : "Write a function <code>createHelloWorld</code>. It should return a new function that always returns <code>"Hello World"</code>.\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> args = []\n<strong>Output:</strong> "Hello World"\n<strong>Explanation:</strong>\nconst f = createHelloWorld();\nf(); // "Hello World"\n\nThe function returned by createHelloWorld should always return "Hello World".\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> args = [{},null,42]\n<strong>Output:</strong> "Hello World"\n<strong>Explanation:</strong>\nconst f = createHelloWorld();\nf({}, null, 42); // "Hello World"\n\nAny arguments could be passed to the function but it should still always return "Hello World".\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>0 <= args.length <= 10</code></li>\n</ul>\n" ,
"translatedTitle" : "创建 Hello World 函数" ,
"translatedContent" : "请你编写一个名为 <code>createHelloWorld</code> 的函数。它应该返回一个新的函数,该函数总是返回 <code>\"Hello World\"</code> 。\n<p> </p>\n\n<p><strong class=\"example\">示例 1: </strong></p>\n\n<pre>\n<b>输入:</b>args = []\n<b>输出:</b>\"Hello World\"\n<strong>解释:</strong>\nconst f = createHelloWorld();\nf(); // \"Hello World\"\n\ncreateHelloWorld 返回的函数应始终返回 \"Hello World\"。\n</pre>\n\n<p><strong class=\"example\">示例 2: </strong></p>\n\n<pre>\n<b>输入:</b>args = [{},null,42]\n<b>输出:</b>\"Hello World\"\n<strong>解释:</strong>\nconst f = createHelloWorld();\nf({}, null, 42); // \"Hello World\"\n\n可以传递任何参数给函数, 但它应始终返回 \"Hello World\"。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 <= args.length <= 10</code></li>\n</ul>\n" ,
"isPaidOnly" : false ,
"difficulty" : "Easy" ,
2023-12-09 18:42:21 +08:00
"likes" : 8 ,
2023-05-15 17:43:00 +08:00
"dislikes" : 0 ,
"isLiked" : null ,
"similarQuestions" : "[]" ,
"contributors" : [ ] ,
2023-12-09 18:42:21 +08:00
"langToValidPlayground" : "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}" ,
2023-05-15 17:43:00 +08:00
"topicTags" : [ ] ,
"companyTagStats" : null ,
"codeSnippets" : [
{
"lang" : "JavaScript" ,
"langSlug" : "javascript" ,
2023-12-09 18:42:21 +08:00
"code" : "/**\n * @return {Function}\n */\nvar createHelloWorld = function() {\n \n return function(...args) {\n \n }\n};\n\n/**\n * const f = createHelloWorld();\n * f(); // \"Hello World\"\n */" ,
2023-05-15 17:43:00 +08:00
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "TypeScript" ,
"langSlug" : "typescript" ,
2023-12-09 18:42:21 +08:00
"code" : "function createHelloWorld() {\n \n\treturn function(...args): string {\n \n };\n};\n\n/**\n * const f = createHelloWorld();\n * f(); // \"Hello World\"\n */" ,
2023-05-15 17:43:00 +08:00
"__typename" : "CodeSnippetNode"
}
] ,
2023-12-09 18:42:21 +08:00
"stats" : "{\"totalAccepted\": \"12.8K\", \"totalSubmission\": \"15.2K\", \"totalAcceptedRaw\": 12815, \"totalSubmissionRaw\": 15159, \"acRate\": \"84.5%\"}" ,
2023-05-15 17:43:00 +08:00
"hints" : [ ] ,
"solution" : null ,
"status" : null ,
"sampleTestCase" : "[]" ,
"metaData" : "{\n \"name\": \"createHelloWorld\",\n \"params\": [\n {\n \"name\": \"args\",\n \"type\": \"string\"\n }\n ],\n \"return\": {\n \"type\": \"string\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}" ,
"judgerAvailable" : true ,
"judgeType" : "large" ,
"mysqlSchemas" : [ ] ,
"enableRunCode" : true ,
2023-12-09 18:42:21 +08:00
"envInfo" : "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/code><\\/p>\\r\\n\\r\\n<p>\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u6267\\u884c\\u65f6\\u5c06\\u5e26\\u4e0a <code>--harmony<\\/code> \\u6807\\u8bb0\\u6765\\u5f00\\u542f <a href=\\\"http:\\/\\/node.green\\/\\\" target=\\\"_blank\\\">\\u65b0\\u7248ES6\\u7279\\u6027<\\/a>\\u3002<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/priority-queue\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 5.1.6<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2022<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/priority-queue\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}" ,
2023-05-15 17:43:00 +08:00
"book" : null ,
"isSubscribed" : false ,
"isDailyQuestion" : false ,
"dailyRecordStatus" : null ,
"editorType" : "CKEDITOR" ,
"ugcQuestionId" : null ,
"style" : "LEETCODE" ,
"exampleTestcases" : "[]\n[{},null,42]" ,
"__typename" : "QuestionNode"
}
}
}