列表

详情


JS5. 创建数组

描述

请补全JavaScript代码,要求返回一个长度为参数值并且每一项值都为参数值的数组。
注意:
1. 请勿直接使用for/while

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1684ms, 内存消耗: 77820KB, 提交时间: 2022-02-10

{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\n            const _createArray = (number) => {\n                // 补全代码\n                 return Array(number).fill(number)\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1742ms, 内存消耗: 77800KB, 提交时间: 2021-12-08

{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\n            const _createArray = (number) => {\n                // 补全代码\n               return Array(number).fill(number)\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1742ms, 内存消耗: 77828KB, 提交时间: 2022-01-03

{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\nconst _createArray = (number) => {\n    // 补全代码\n    return new Array(number).fill(number)\n}\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1742ms, 内存消耗: 77900KB, 提交时间: 2021-12-07

{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\n            const _createArray = (number) => {\n                // 补全代码\n                let temp = new Array(number)\n                temp.fill(number)\n                return temp\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1743ms, 内存消耗: 77808KB, 提交时间: 2021-12-05

{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\n            const _createArray = (number) => {\n                // 补全代码\n              return Array(number).fill(number)  \n            }\n        </script>\n    </body>\n</html>","libs":[]}

上一题