I am trying to make a 2D array javascript using looping, with a result like this:
[[a1,a2,a3,a4,a5][b1,b2....]..[...e3,e4,e5]]
I have tried multiple different things, using for loops and the below, but am unable to create as needed.
var cols = [1,2,3,4,5];
var rows = ["a", "b", "c","d", "e"];
var grid = [ for (r of rows) [ for (c of cols) r+c ] ];
any help is appreciated.
Thanks
x. first loop rows and initialize an empty array inside first loop say 'y'. then loop cols and inside that loop push to y the sum of elements. after the second loop finish push the y to x