Home >Web Front-end >JS Tutorial >Use Javascript to easily create a simple lottery system_javascript skills
Author: jegg
The end of the year is approaching, and many companies are busy holding annual meetings. There will usually be some lottery activities at the meeting. The following program is a simple lottery system written in javascript to share with everyone.
This code draws on the codes of some netizens on the Internet, and adds some improvements such as no repeated draws. The general idea is as follows:
1. Store all lottery data (here, mobile phone number) into an array.
2. Use the random function to randomly generate the INDEX of the array
3. Use the setInterval function to generate the mobile phone number corresponding to the random INDEX of the array at a very short time interval and display it.
4. Use the removeEleAt(index) function to delete randomly generated mobile phone numbers. And reorganize and generate the remaining mobile phone numbers into a new array for next use.
How to use:
Copy the following original code to the writing board, and then change the txt attribute to html. If garbled characters appear, please change the web page encoding (View - Encoding).
The original code is as follows: