当前位置:网站首页>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
边栏推荐
- SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
- 数据库查询优化的方式
- 12. Constraints
- [self motivation series] you'll never be ready
- Methods of database query optimization
- Nacos / sentinel gateway current limiting and grouping (code)
- typescript字典的使用
- 反转链表练习
- ABAP 从CDS VIEW 发布OData Service示例
- Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
猜你喜欢
Super classic & Programming Guide (red and blue book) - Reading Notes
如何判断点是否在多边形内(包含复杂多边形或者多边形数量很多的情况)
MySQL index
SAP PI/PO Soap2Proxy 消费外部ws示例
Reflection on the systematic design of Android audio and video caching mechanism
如何SQL 语句UNION实现当一个表中的一列内容为空时则取另一个表的另一列
h5本地存储数据sessionStorage、localStorage
SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?
SAP 03-AMDP CDS Table Function using ‘WITH‘ Clause(Join子查询内容)
设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?
随机推荐
BTree、B+Tree和HASH索引
MySQL storage engine
SAP PI/PO Soap2Proxy 消费外部ws示例
Implementation of MySQL persistence
js之函数的两种声明方式
手游的热更方案与动态更新策略
ABAP 从CDS VIEW 发布OData Service示例
1.查看数据库和表
3. Sort statement
ABAP 实现发布RESTful服务供外部调用示例
SAP TRANSLATE使用数据对象掩码示例
Use of typescript dictionary
[hdu6833]A Very Easy Math Problem(莫比乌斯反演)
h5本地存储数据sessionStorage、localStorage
js之排他思想及案例
页面动态显示时间(升级版)
SAP 03-AMDP CDS Table Function using ‘WITH‘ Clause(Join子查询内容)
Nacos / sentinel gateway current limiting and grouping (code)
Authorization+Token+JWT
Mysql 索引