【发布时间】:2021-09-23 19:37:22
【问题描述】:
function multiplyer(...arr){
let res=[],product=1;
for(var j=arr.length-1;j>=0;j--){
res.unshift(arr[j].map(item=>item*product))
product*=10
}
return res;
}
console.log(multiplyer([[2,3][3,5]]))
我期待像[[20,30][3,5]] 这样的东西,但我认为我在访问二维数组的元素时遇到了问题。结果为[ [ NaN ] ]
【问题讨论】:
-
[ [ 2, 3 ][ 3, 5 ] ]与[ undefined ]相同。你的意思是[ [ 2, 3 ], [ 3, 5 ] ]。
标签: javascript arrays array.prototype.map