Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help trying to figure out how to make this work please thank you <html lang

ID: 645294 • Letter: N

Question

need help trying to figure out how to make this work please thank you

<html lang="en">


   <head>
       <meta charset="utf-8">
       <title>multiplication</title>
   </head>

   <body>
       <h1>Multiplication Table</h1>
       <script>
"use strict";
function mult(x,y) {
   return x * y;
}

function generate_table() {
   var x_values = [1,2,3,4,5,6,7,8,9,10];
   var y_values = [1,2,3,4,5,6,7,8,9,10];
   // the table starts empty
   var table = "<table>";
   //var matrix = [];
   var row;
   // TODO - Generate the rows and colums of the multiplication table.
   // This requires two nested for loops. The outer for loop generates
   // a row and the inner for loop generates the columns of each row.
   // For example, at the end of the first interation of the outer loop
   // you should have row === "<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr>"
   //
   // At this point the outer for loop should be completed and
   // the table contents are complete, so generate the end table tag
   table += "</table>";
   var heading = "<h1>Multiplication Table</h1>";
   document.write(heading + table);
}

window.onload = generate_table;

       </script>
   </body>
</html

Explanation / Answer

<html lang="en">

    <head>
        <meta charset="utf-8">
        <title>multiplication</title>
    </head>

    <body>
        <h1>Multiplication Table</h1>
        <script>
"use strict";
function mult(x,y) {
    return x * y;
}

function generate_table() {
    var x_values = [1,2,3,4,5,6,7,8,9,10];
    var y_values = [1,2,3,4,5,6,7,8,9,10];
    // the table starts empty
    var table = "<table>";
    //var matrix = [];
    var row;
    // TODO - Generate the rows and colums of the multiplication table.
    //        This requires two nested for loops. The outer for loop generates
    //        a row and the inner for loop generates the columns of each row.
    //        For example, at the end of the first interation of the outer loop
    //        you should have row === "<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr>"
    //
    // At this point the outer for loop should be completed and
    // the table contents are complete, so generate the end table tag
   var i = 0;
   var j = 0;
   for(i = 0; i < 10; ++i){
       table += "<tr>";
       for(j = 1; j <= 10; ++j){
           table += "<td>" + j + "</td>";
       }
       table += "</tr>";
   }
    table += "</table>";
    var heading = "<h1>Multiplication Table</h1>";
    document.write(heading + table);
}

window.onload = generate_table;

        </script>
    </body>
</html