当前位置:网站首页>简易随机点名抽奖(js下编写)
简易随机点名抽奖(js下编写)
2022-04-23 06:24:00 【资深咸鱼~】
随机抽三个人出来且不重复
<script type="text/javascript">
//选3个人,且不重复
var names = ["严峫", "停停", "蒋丞", "顾飞", "江添"]
var choice = []
for (var i = 1; i <= 3; i++) {
var index1 = Math.round(Math.random() * (names.length - 1 - 0 + 1) + 0)
if (choice.every(function (item, index) {
return item != names[index1]
}) == true && names[index1] != undefined) {
choice.push(names[index1])
} else {
i = i - 1
}
}
console.log(choice)
</script>
输出结果展示


其中主要功能代码同样适用于其他语言环境
版权声明
本文为[资深咸鱼~]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_51644702/article/details/123902385
边栏推荐
- Mysql的存储引擎
- Solution of emergency communication system for major security incidents
- [hdu6833]A Very Easy Math Problem(莫比乌斯反演)
- Mysql 数据库从设计上的优化
- 可视化常见问题解决方案(七)画图刻度设置解决方案
- ES6之箭头函数细谈
- Emergency communication system for flood control and disaster relief
- Object.create()原理,Object.create()规范,手写Object.create(),Object.create()用法
- What is a closure?
- colab
猜你喜欢

数论分块(整除分块)

Take you to travel in space, and American photography technology provides comprehensive technical support for aerospace creative applet

javscript获取文件真实后缀名

关于'enum'枚举类型以及结构体的问题。

自定义时间格式(YYYY-MM-DD HH:mm:ss 星期X)

Beifeng communication helps Zhanjiang fire brigade build PDT wireless communication system

数据分析入门 | kaggle泰坦尼克任务(四)—>数据清洗及特征处理

el-date-picker中自定义快捷选项picker-options,动态设置禁用日期

How to improve the service efficiency of the hotel without blind spots and long endurance | public and Private Integrated walkie talkie?

Educational Codeforces Round 81 (Rated for Div. 2)
随机推荐
van-uploader上传图片实现过程、使用原生input实现上传图片
数据分析入门 | kaggle泰坦尼克任务(三)—>探索数据分析
xdotool按键精灵
el-table的数据更新后,页面中数据未更新this.$forceUpdate()无效果
Dirichlet 前缀和(数论优化式子复杂度利器)
P1446 [HNOI2008]Cards(Burnside定理+dp计数)
可视化之路(十)分割画布函数详解
可视化常见绘图(五)散点图
可视化常见问题解决方案(九)背景颜色问题
What is a closure?
保洁阿姨都能看懂的中国剩余定理和扩展中国剩余定理
Mysql隔离级别
anaconda3安装
colab
使用compressorjs压缩图片,优化功能,压缩所有格式的图片
H5案例开发
[CodeForces - 208E] Blood Cousins(k代兄弟问题)
数论之阶与原根讲解
Meishe helps Baidu "Duka editing" to make knowledge creation easier
12.约束