Note that there are some explanatory texts on larger screens.

plurals
  1. POCall functions from array into table
    text
    copied!<p>I am trying to call several functions which contain simple math problems using a random number into an array then into a table. I think I am close, I am just unsure of how to write the table. I have as follows:</p> <p>HTML: </p> <pre><code>&lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;table id="content"&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>SCRIPT:</p> <pre><code>function RandX(){ var x = Math.floor(Math.random()*300); } function RandY(){ var y = Math.floor(Math.random()*300); } var math1 = function(x,y) {return x * y;}; var math2 = function(x,y) {return x + 1;}; var math3 = function(x,y) {return x/y;}; var math4 = function(x,y) {return x % y;}; var math5 = function(x,y) {return math.sqrt(x^2 + y^2);}; var math6 = function(x,y) {return x^2;}; var math7 = function(x,y) {return (10*x) + (y/2);}; var math8 = function(x,y) {return SIGMA) var maths = []; maths.push(math1); maths.push(math2); maths.push(math3); maths.push(math4); maths.push(math5); maths.push(math6); maths.push(math7); maths.push(math8); //maths[0](RandX,2);//return RandX* RandY //maths[1](3,4);//12 - put random numbners here? var c = document.getElementById("Content"); var content = document.createElement("tr"); for( var i = 0; i &lt; maths.length; i++ ){ var d = document.createElement("&lt;td&gt;" + "&lt;/td&gt;); d.innerHTML = "&lt;td&gt;" + maths[0](RandX(), RandY()) + "&lt;/td&gt;"; content.appendChild(d); } c.appendChild(content); </code></pre> <p>Thank you!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload