Multiple column logic in javascript [closed]
Does anyone has the logic to display array of data in multiple column in java script like
1 2 3
4 5 6 7 8 9and not
1 4 7
2 5 8 3 6 9thank you
It's all how you step through the indices. Looks like you have your indices switched somewhere.
You're ordering by rows. You need to know how many rows and columns you have. Then your code will look like this (pseudocode):
for i = 0 to numColumns - 1
for j = 0 to numRows - 1
print array value at i + (numColumns * j)
next
print newline
next
精彩评论