خرید بک لینک
In the following code, could someone explain
where the extra lines of ',,,,,' before the last table
are coming from when the program is executed?
:confused:

The first display of the original 2-diminsion array
elements multiplied by 4 do not show the problem.
Code:


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title> HTML5 page </title>
</head>
<body>
<pre id="debug"></pre>

<script>
var arr2 = [
  [0,1,2,3,4], [5,6,7,8,9], [10,11,12,13,14], [15,16,17,18,19], [20,21,22,23,24]
];

function test() { 
  var tarr = arr2.map( function(a) {
              return a.map( function(b) { return b * 4; } )
            } );
  return tarr;
}

function test2() { 
  var tarr = arr2.map( function(a) {
              return '<tr>' + a.map( function(b) { return '<td>'+b+'</td>'; } ) + '</tr>';
            } );
  return tarr;
}

function init() {
  document.getElementById('debug').ierHTML = 'Original 2-dim array<br>'+arr2.join('<br>');

  document.getElementById('debug').ierHTML += '<br><br>Modified: * 4<br>'+test().join('<br>');

  document.getElementById('debug').ierHTML += '<br><br>Table display:<br>'
                                              + '<table border="1">'
                                              + test2().join('<br>')
                                              + '</table>';
} init();

</script>
</body>
</html>

برچسب: نویسنده: آیلین رضوانی تاريخ: جمعه 22 دی 1396 ساعت: 5:14

صفحه بندی