Skip to content

Latest commit

 

History

History
13 lines (12 loc) · 283 Bytes

0313.md

File metadata and controls

13 lines (12 loc) · 283 Bytes

1-100找50个随机不重复值(打乱数组)

  • 不是最优解,以后有好的可以改
  let arr = [];
  for (let index = 0; index <100; index++) {
    arr.push(index);
  }
  arr.sort((a, b) => {
    return 0.5 - Math.random();
  });
  console.log(arr);