1、生成随机数
const randomStr= () => Math.random().toString(16).slice(2)
2、数组去重
const removeDuplicates = (arr) => [...new Set(arr)]
console.log(removeDuplicates([1, 2, 2, 3, 3, 4, 4, 5, 5, 6]))
//Array(6) [ 1, 2, 3, 4, 5, 6 ]
3、两个数之间的随机整数
const randomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
console.log(randomNumber(1, 50) )
4、计算两个日期相差天数
const intervalDays = (date, otherDate) => Math.ceil(Math.abs(date - otherDate) / (1000 * 60 * 60 * 24));