It is necessary to bring the elements of the array, entered through the function suma by another function Vivod, to the list in the html document itself. Sum Works correctly, there is an array. Code:
<!DOCTYPE html> <html> <head> <title>Практическая работа 5.4</title> <meta charset= "UTF-8"> <script> function suma(){ for (i=0; x !== 0; i++){ x = parseInt(prompt("введите число:",'')); numbers[i] = x; if (( x % 5 === 0) && (x === 5)) {sum += x;} if (x > 0) {pro *= x;} } } //вот тут ошибка, что не так? function Vivod(){ var size; document.open(); document.write("<ol>"); for(size = 0; size < i-1; size ++){ document.write("<li>"); document.write(numbers[i]); document.write("</li>"); } document.write("</ol>"); document.close(); } </script> </head> <body> <script> var sum=0; var pro=1; var x=1; var i; var numbers = []; suma(); </script> <table height=200 width=300 border="solid" cellspacing=1> <tr> <td>Сумма чисел, кратных 5: <script>document.write(sum)</script></td> </tr> <tr> <td>Произведение положительных чисел: <script>document.write(pro)</script></td> </tr> </table> <script> vivod(); </script> </body> </html>
myWindowvariable? Where is it initialized? - Stepan Kasyanenko FebruaryVivod, and youvivod(). Register matters! - Stepan Kasyanenko Feb.numbers[i]be replaced bynumbers[size]? - Stepan Kasyanenko Feb.