Complecated Loop
by Korah Babu Varghese
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div id="html">
</div>
<div id="html1">
</div><pre id="html2">
</pre>
JavaScript
var t=[[1, 2, 3],
[4, 5],
[7, 8, 9],
[7, 8, 9,8],
[7]];
document.getElementById('html').innerHTML=JSON.stringify(t);
document.getElementById('html1').innerHTML=JSON.stringify(t.length);
var hello=[];
for (var i = 0; i < t.length; i++) {
for (var j = 0; j <= i; j++) {
var temp = t[i][j] ? t[i][j] : 0;
t[i][j] = t[j][i] ? t[j][i] : 0;
t[j][i] = temp ? temp : 0;
}
hello.push({name:i,data:t[i]});
}
console.log(t)
document.getElementById('html2').innerHTML=JSON.stringify(hello);