const axaliGamoshveba = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
];
for (let i = 0; i < gamoshvebisMult.length; i ) {
axaliGamoshveba[0].push(gamoshvebisMult[i].Soflis);
axaliGamoshveba[1].push(gamoshvebisMult[i].Samto);
axaliGamoshveba[2].push(gamoshvebisMult[i].Damamushavebeli);
axaliGamoshveba[3].push(gamoshvebisMult[i].Eleqtroenergiis);
axaliGamoshveba[4].push(gamoshvebisMult[i].Wyalbobarageba);
axaliGamoshveba[5].push(gamoshvebisMult[i].Mshenebloba);
axaliGamoshveba[6].push(gamoshvebisMult[i].Sabitumo);
axaliGamoshveba[7].push(gamoshvebisMult[i].Transporti);
axaliGamoshveba[8].push(gamoshvebisMult[i].Gantavsebis);
axaliGamoshveba[9].push(gamoshvebisMult[i].Informacia);
axaliGamoshveba[10].push(gamoshvebisMult[i].Safinanso);
axaliGamoshveba[11].push(gamoshvebisMult[i].UdzraviQoneba);
axaliGamoshveba[12].push(gamoshvebisMult[i].Profesiuli);
axaliGamoshveba[13].push(gamoshvebisMult[i].Administraciuli);
axaliGamoshveba[14].push(gamoshvebisMult[i].Saxelmwifo);
axaliGamoshveba[15].push(gamoshvebisMult[i].Ganatleba);
axaliGamoshveba[16].push(gamoshvebisMult[i].Jandacva);
axaliGamoshveba[17].push(gamoshvebisMult[i].Xelovneba);
axaliGamoshveba[18].push(gamoshvebisMult[i].Sxva);
axaliGamoshveba[19].push(gamoshvebisMult[i].Shinameurneoba);
}
I have my array from MySQL server and want to create matrix, but when I push my arrays like that, it adds horizontally.
CodePudding user response:
join the items with newlines:
var axaliGamoshveba = ['one', 'two', 'three']
element.textContent = array.join('\n')
CodePudding user response:
What do you mean by - How can I push array in matrix vertically ?
If you want to print the array items vertically, then you can print each element vertically by using Array.join(<br>
)
Demo :
const axaliGamoshveba = [["Alpha"], ["Beta"], ["Gama"], ["Omega"]];
document.getElementById('result').innerHTML = axaliGamoshveba.join('<br>');
<div id="result"></div>