A super simple JavaScript project that randomly picks a winner from a list of participants.
Perfect for beginners learning arrays, random numbers, and Node.js basics!
The program:
- Stores a list of participant names in an array.
- Uses
Math.random()to generate a random number between 0 and 1. - Multiplies that number by the array length to match a participant’s index.
- Uses
Math.floor()to round it down to a whole number. - Selects the name at that random index and displays it as the winner. 🎉
touch raffle.js