当前位置:网站首页>简易随机点名抽奖(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
边栏推荐
猜你喜欢
Background management system framework, there is always what you want
Discussion on frame construction and technology selection of short video platform
Typora操作技巧说明(一).md
Authorization+Token+JWT
学习笔记5-梯度爆炸和梯度消失(K折交叉验证)
自定义时间格式(YYYY-MM-DD HH:mm:ss 星期X)
配置npm
可视化之路(十一)matplotlib颜色详解
H5案例开发
USO technology was invited to share the technical framework and challenges of AI synthetic virtual characters at lvson2020 conference
随机推荐
技能点挖坑
anaconda3安装
基于可视化结构的身份证号码校验系统-树莓派实现
13.用户和权限管理
青龙面板拉库命令更新【2022/4/20】收藏不走丢
Transformer的pytorch实现
remote: Support for password authentication was removed on August 13, 2021.
可视化常见绘图(五)散点图
快速傅里叶变换FFT简明教程
可视化常见问题解决方案(九)背景颜色问题
Machine vision series (01) -- Overview
数据分析入门 | kaggle泰坦尼克任务(四)—>数据清洗及特征处理
嵌入式相关面经(一)
菜菜的并发编程笔记 |(五)线程安全问题以及Lock解决方案
可视化之路(十)分割画布函数详解
colab
Educational Codeforces Round 81 (Rated for Div. 2)
Failed to install Tui editor, quick solution
[COCI]Lampice (二分+树分治+字符串哈希)
H5 case development