gpt4 book ai didi

javascript - 如何在数字组之间设置 math.random

转载 作者:行者123 更新时间:2023-12-01 00:56:42 24 4
gpt4 key购买 nike

我尝试在一组数字之间设置 Math.random 值,但多次失败,并且不知道如何执行此操作。

我之前尝试过的是设置 math.floor(Math.random()* 400) - 200;查看该函数是否会得到 400 到 200 之间的数字。

Math.floor(Math.random() * 400) - 200;

但是该函数最终取了给定的数字并减去 200

最佳答案

我认为你想要Math.random() * 200 + 200;

关于javascript - 如何在数字组之间设置 math.random,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56517424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com