我正在尝试使用随机数将包含简单数学问题的几个函数调用到数组中,然后调用到表中。我想我很接近,我只是不确定如何写表格。我有如下:
HTML:
</head>
<body>
<div>
<table id="content">
</table>
</div>
</body>
</html>
脚本:
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 < maths.length; i++ ){
var d = document.createElement("<td>" + "</td>);
d.innerHTML = "<td>" + maths[0](RandX(), RandY()) + "</td>";
content.appendChild(d);
}
c.appendChild(content);
谢谢!