There is a code, its task is to output an array sorted in ascending order to the console and to the page. It displays everything correctly to the console, but it does not output a sorted array to the page. Help to display the sorted array on the page. Thank you in advance!
table{ width: 100%; } table td{ font-family: Courier New; font-weight: bolder; font-size: 20px; text-align: center; padding: 10px; border: 1px solid black; } td{ background-color: yellow; } .parentElem{ border: 2px solid black; width: 50%; background-color: red; } #elem{ opacity: 0; } </style> <input type="button" onClick="elem.style.opacity=1;"> <div class="parentElem"> <div id="elem"></div> </div> <script> function getRandomInt(min, max){//Π€ΡΠ½ΠΊΡΠΈΡ Π΄Π»Ρ Π³Π΅Π½Π΅ΡΠ°ΡΠΈΠΈ ΡΠ»ΡΡΠ°ΠΉΠ½ΠΎΠ³ΠΎ ΡΠΈΡΠ»Π° return Math.floor(Math.random() * (max - min)) + min; } function compareNumbers(a, b) {//Π€ΡΠ½ΠΊΡΠΈΡ Π΄Π»Ρ ΡΠΎΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΌΠ°ΡΡΠΈΠ²Π° return a - b; } function matrixArray(rows,columns){ //Π€ΡΠ½ΠΊΡΠΈΡ, ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠΎΠ·Π΄Π°ΡΡ Π΄Π²ΡΠΌΠ΅ΡΠ½ΡΠΉ ΠΌΠ°ΡΡΠΈΠ² var arr = new Array(); for(var i=0; i<rows; i++){ arr[i] = new Array(); for(var j=0; j<columns; j++){ arr[i][j] = getRandomInt(0, 100); } } return arr; } var myMatrix = matrixArray(7,5); myMatrix.forEach(row => row.sort(compareNumbers));//ΠΡΠ·ΠΎΠ² ΡΡΠ½ΠΊΡΠΈΠΈ, ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠΎΡΡΠΈΡΡΠ΅Ρ ΠΌΠ°ΡΡΠΈΠ² ΠΏΠΎ rows console.log(myMatrix); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var elem = document.querySelector('#elem'); createTable(elem, 5, 7); function createTable(parent, cols, rows){ var table = document.createElement('table'); for (var i = 0; i < rows; i++) { var tr = document.createElement('tr'); for(var j = 0; j < cols; j++){ var td = document.createElement('td'); td.innerHTML=getRandomInt(0,100); tr.appendChild(td); } table.appendChild(tr); } parent.appendChild(table); } </script>
td.innerHTML=getRandomInt(0,100);where is your array here? - ThisMan