Answer the question
In order to leave comments, you need to log in
How to reverse the result of a loop?
There is a cycle:
var namber = 3;
var namberTwo = namber * namber;
for (var i = 1; i <= namber; i += 1) {
process.stdout.write(i + "\t");
for (var a = i + namber; a <= namberTwo; a += namber) {
if (a <= (namberTwo - namber)) {
process.stdout.write(a + "\t");
} else {
process.stdout.write(a + "\n");
}
}
}
1 4 7
2 5 8
3 6 9
3 2 1
6 5 4
9 8 7
Answer the question
In order to leave comments, you need to log in
var num = 3;
for (var i = 1; i <= num; i++) {
for (var j = 0; j < num; j++) {
process.stdout.write(`${i * num - j}\t`);
}
process.stdout.write('\n');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question