javascript
\nvar matrixReshape = function(nums, r, c) {\n    const r0 = nums.length, c0 = nums[0].length, result = [];\n    if(r * c != r0 * c0) {\n        return nums;\n 
```\nvar matrixReshape = function(nums, r, c) {\n    const r0 = nums.length, c0 = nums[0].length, result = [];\n    if(r * c != r0 * c0) {\n        return nums;\n    }\n    let array = [];\n    for(let i = 0; i < r0; i++) {\n        for(let j = 0; j < c0; j++) {\n            array.push(nums[i][j]);\n        }\n    }\n    while(array.length) {\n        result.push(array.splice(0, c));\n    }\n    return result;\n};\n```
[]