From d5a22f12f85a9986d40c6544df343b7e224e7502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ce?= <2678062447@qq.com> Date: Thu, 24 Feb 2022 20:39:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4node=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index.js" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "\345\220\264\345\217\214\345\272\206/0224 \347\254\254\344\272\214\346\254\241\350\257\276\344\275\234\344\270\232/index.js" diff --git "a/\345\220\264\345\217\214\345\272\206/0224 \347\254\254\344\272\214\346\254\241\350\257\276\344\275\234\344\270\232/index.js" "b/\345\220\264\345\217\214\345\272\206/0224 \347\254\254\344\272\214\346\254\241\350\257\276\344\275\234\344\270\232/index.js" new file mode 100644 index 0000000..2dc8400 --- /dev/null +++ "b/\345\220\264\345\217\214\345\272\206/0224 \347\254\254\344\272\214\346\254\241\350\257\276\344\275\234\344\270\232/index.js" @@ -0,0 +1,14 @@ +let fs = require("fs"); + +function randomPrize() { + let prize = ["你不知道的JavaScript", "Python从入门到精通", "Node.js深入浅出", "谢谢参与"] + return prize[Math.floor(Math.random() * prize.length + 0)] +} + + +for (let i = 1; i < 7; i++) { + fs.writeFile(`第${i}个文件.txt`, `${randomPrize()}`, err => { + if (err) return console.log("写入文件失败", err); + console.log("写入文件成功"); + }) +} \ No newline at end of file -- Gitee