题解 | #创建数组#
创建数组
https://www.nowcoder.com/practice/04a6204cd4cf42dd8983c000110ada7e
通过tostring方法将数字转化为字符串再用repeat方法填满数组,最后用map方法将字符数组转化为字符串数组
<!DOCTYPE html> <html> <head> <meta charset=utf-8> </head> <body> <script type="text/javascript"> const _createArray = (number) => { // 补全代码 var kk=number.toString().repeat(number); return kk.split('').map(Number); } // console.log(_createArray(5)); </script> </body> </html>