欢迎光临散文网 会员登陆 & 注册

李振良 Go/Golang DevOps运维开发实战集训营

2022-10-12 21:09 作者:抽抽一生恋  | 我要投稿

在两个数字之间生成一个随机数
这将以两个数字为参数,并将在这两个数字之间生成一个随机数!

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!!!


李振良 Go/Golang DevOps运维开发实战集训营的评论 (共 条)

分享到微博请遵守国家法律