Matrix of numbers javascript
问题 I need help with a function in JS that prints a matrix by a given integer N like this: N = 2; Matrix: 1 2 2 3 N = 3; Matrix: 1 2 3 2 3 4 3 4 5 I need to make it with 2 loops but I can't figure out how function solve(args) { var n = args[0]; } PS: Sorry for inserting the matrixes into JS code but that way I could visualise the result. 回答1: Here is the logic function paintMatrix(n) { for (var i = 1; i <= n; i++) { var result = ""; for (var j = 1; j <= n; j++) { result += (i + j - 1); } console