当前位置:网站首页>Simple random roll call lottery (written under JS)
Simple random roll call lottery (written under JS)
2022-04-23 07:45:00 【Senior salted fish~】
Take three people at random and don't repeat
<script type="text/javascript">
// choose 3 personal , And not repeated
var names = [" Yan Yu ", " Stop ", " Jiang Cheng ", " Gu Fei ", " Jiang Tian "]
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>
The output shows


The main function codes are also applicable to other language environments
版权声明
本文为[Senior salted fish~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230623087305.html
边栏推荐
- 公共依赖模块common的处理
- NPM installation stepping pit
- 安装配置淘宝镜像npm(cnpm)
- [self motivation series] what really hinders you?
- Redis connection error err auth < password > called without any password configured for the default user
- SAP CR传输请求顺序、依赖检查
- 2. Restricted query
- ABAP 从CDS VIEW 发布OData Service示例
- F-牛妹的苹果树(直径合并)
- canvas学习第一篇
猜你喜欢
随机推荐
canvas学习第一篇
Date对象(js内置对象)
js之排他思想及案例
H5 case development
8. Paging query
Visualization Road (IX) detailed explanation of arrow class
On BFC (block formatting context)
Mvcc (multi version concurrency control)
SAP PI/PO rfc2RESTful 發布rfc接口為RESTful示例(Proxy間接法)
MySQL index
h5本地存储数据sessionStorage、localStorage
[COCI] Vještica (子集dp)
Mysql 数据库从设计上的优化
面经的总结
10.更新操作
SAP PI/PO登录使用及基本功能简介
7.子查询
Learn to use search engines
ABAP 实现发布RESTful服务供外部调用示例
13. User and authority management









