我正在尝试在ES6中生成随机数数组-不应重复数字。
当前,我的函数生成一个随机数数组,但它们在重复:
winArray = [...Array(6)].map(() => Math.floor(Math.random() * 53));
Run Code Online (Sandbox Code Playgroud)
使用Set的此解决方案未在for循环中运行:
for (let i = 1; i <= draws; i += 1) {
// Generating a random array of 6 number
const winArray = new Set();
while (winArray.size < 6) winArray.add(Math.floor(Math.random() * 53));
}
Run Code Online (Sandbox Code Playgroud) 我希望 ESLint 忽略我的“views”文件夹并为此在项目根目录中创建一个 .eslintignore 文件。
在里面,我添加了我想忽略的文件夹:
/views
但它不起作用(是否需要在 package.json 中添加一些配置?)。
我不想/* eslint-disable */
在需要忽略的文件顶部使用。