当前位置:网站首页>简易随机点名抽奖(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
边栏推荐
- 青龙面板拉库命令更新【2022/4/20】收藏不走丢
- Javscript gets the real suffix of the file
- Metro wireless intercom system
- pytorch:关于GradReverseLayer实现的一个坑
- 1. View databases and tables
- Authorization+Token+JWT
- Beifeng communication helps Zhanjiang fire brigade build PDT wireless communication system
- 使用compressorjs压缩图片,优化功能,压缩所有格式的图片
- Statement of American photography technology suing Tianmu media for using volcanic engine infringement code
- 数据分析学习(一)数据分析和Numpy基础
猜你喜欢
随机推荐
安装配置淘宝镜像npm(cnpm)
[2020WC Day2]F.采蘑菇的克拉莉丝(子树和查询、轻重儿子思想)
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?
javscript获取文件真实后缀名
1. View databases and tables
Typora操作技巧说明(一).md
Moment.js中format方法函数的格式
LATEX公式注意事项
[self motivation series] you'll never be ready
2022.3.14 阿里笔试
13.用户和权限管理
数据分析入门 | kaggle泰坦尼克任务(四)—>数据清洗及特征处理
HuggingFace
Object.create()原理,Object.create()规范,手写Object.create(),Object.create()用法
ESP32学习-GPIO的使用与配置
按需引入vant组件
Authorization+Token+JWT
1D/1D动态规划学习总结
The people of Beifeng have been taking action









