console.log()
在循环的每个循环中打印变量值可以发现与重置相关的错误行为,或者无法重置变量。 m
行和n
列零的二维数组。不幸的是,它没有产生预期的输出,因为row
变量没有在外部循环中重新初始化(设置回空数组)。修复代码,使其返回正确的3x2零数组,看起来像[[0, 0], [0, 0], [0, 0]]
。 matrix
变量设置为一个数组,每个数组包含3行,每列2列零。
testString: 'assert(JSON.stringify(matrix) == "[[0,0],[0,0],[0,0]]", "Your code should set the matrix
variable to an array holding 3 rows of 2 columns of zeroes each.");'
- text: matrix
变量应该有3行。
testString: 'assert(matrix.length == 3, "The matrix
variable should have 3 rows.");'
- text: matrix
变量每行应有2列。
testString: 'assert(matrix[0].length == 2 && matrix[1].length === 2 && matrix[2].length === 2, "The matrix
variable should have 2 columns in each row.");'
```