用JS,编写一个函数,在页面上输出一个N行M列的表格,表格内容填充0~100的随机数字
整数随机:parseInt(Math.random(i)*100)
Math.round(Math.random() * 100) ,Math.round()方法将对参数进行四舍五入操作。
writeln()和write()的区别是,前者多一个空格和会换行
function conut(n, m) {
// 给table头
document.write("<table>");
for (var i = 0; i < n; i++) { //外层循环 作用行
// 给表的行rows 头
document.write("<tr>");
for (var j = 0; j < m; j++) { //内层循环 作用列
// 给表的列columns 头
document.write("<td>");
// document.write(Math.round(Math.random() * 100));
document.write(parseInt(Math.random() * 100));
// 给表的列columns 尾
document.write("</td>");
}
// 给表的行rows 尾
document.write("</tr>");
}
// 给table尾
document.write("</table>");
}
conut(5, 10);