当前位置:网站首页>简易随机点名抽奖(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
边栏推荐
猜你喜欢
el-table 横向滚动条固定在可视窗口底部
保洁阿姨都能看懂的中国剩余定理和扩展中国剩余定理
Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference
可视化之路(十)分割画布函数详解
keytool: command not found
记录一个查询兼容性的网站,String.replaceAll()兼容性报错
Discussion on the outline of short video technology
Us photo cloud editing helps BiliBili upgrade its experience
Take you to travel in space, and American photography technology provides comprehensive technical support for aerospace creative applet
Machine vision series (01) -- Overview
随机推荐
菜菜的并发编程笔记 |(九)异步IO实现并发爬虫加速
[LNOI2014]LCA——树链剖分——多点LCA深度和问题
[hdu6868]Absolute Math(推式子+莫比乌斯反演)
anaconda3安装
后台管理系统框架,总有你想要的
1. View databases and tables
null和undefined的区别
技能点挖坑
可视化常见问题解决方案(八)数学公式
数论之拓展欧几里得
[self motivation series] you'll never be ready
可视化常见问题解决方案(八)共享绘图区域问题解决方案
[Ted series] how to get along with inner critics?
页面动态显示时间(升级版)
嵌入式相关面经(一)
[牛客练习赛68]牛牛的粉丝(矩阵快速幂之循环矩阵优化)
vim+ctags+cscpope开发环境搭建指南
快速傅里叶变换FFT简明教程
反思 | 事件总线的局限性,组件化开发流程中通信机制的设计与实现
Source Insight 4.0常见问题