- let i = 0, txt = '';
- while (i < 50) {
- let a = Math.floor(Number(Math.random() * 11)),
- b = Math.floor(Number(Math.random() * 11)),
- c = Math.floor(Math.random() * 2),
- d = c ? a + b : a - b,
- e = c ? '+' : '-',
- f = '"'+a + e + b + '="';
- if (d >= 0 && d <= 10) {
- i++;
- if (i % 5) {
- txt += (f + ',');
- } else {
- txt += (f + '\n');
- }
- }
- }
- console.log(txt);
-
- let alink = document.createElement("a");
- if (window.Blob && window.URL && window.URL.createObjectURL) {
- const csvDataBlob = new Blob([txt], {
- type: "text/csv",
- });
- alink.href = URL.createObjectURL(csvDataBlob);
- }
- document.body.appendChild(alink);
- alink.setAttribute("download", '十以内数学50题');
- alink.click();
- document.body.removeChild(alink);

小朋友学数学实在是件头疼的事,平时不知道自己学习,想到通过考试的办法来促进他的数学学习。可以通过这个工具来生成50道结果10以内的数学题,平时他要看电影的时候,就用这个来检验他的学习情况。
利用这个工具可以直接生成excel,并打印出来,让小朋友笔答
这篇文章包含的知识点有:
注意:CSV这里是用逗号切换单元格,文本两端有双引号
我用的录屏软件是 Gifcam