李振良 Go/Golang DevOps运维开发实战集训营
在两个数字之间生成一个随机数
这将以两个数字为参数,并将在这两个数字之间生成一个随机数!
const random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);console.log(random(1, 50));// could be anything from 1 - 50
07-生成随机字符串(唯一ID?)
也许你需要临时的唯一ID,这是一个技巧,你可以使用它在旅途中生成随机字符串。
const randomString = () => Math.random().toString(36).slice(2);console.log(randomString());// could be anything!!!

