我的代码:
arr = [1,2,3,4,5,6]
function printArray(arr){
arrAtr = "";
for(count = 0; count < arr; count++){
arrAtr += (String(arr[count]) + " ")
}
document.write(arrAtr);
}
printArray(arr)
这不会打印数组。我期待:
1 2 3 4 5 6
最佳答案
您的代码中有错误。
你必须更换
printArray(myArr)
与
printArray(arr);
并替换
for(count = 0; count < arr; count++){
与
for(count = 0; count < arr.length; count++){
关于javascript - 为什么这个数组不打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37349252/