Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/School-Work / School Work/forLoopLottery.js |
| Date | Not specified in source |
| Repository | Janady13/School-Work |
| Revision | 4a666c890caf7c43c47d0572dbcc287373c7a78e |
| Branch | main |
| Path or archive member | School Work/forLoopLottery.js |
| Original SHA-256 | 8bc7110e818428d0b933d50b5969f61ae51d75c50b6dabc308664dd566b2a1cb |
| Git blob SHA | 0e3f56c568006924435fe7b7ae7a9628893c4f0c |
| Reading-copy SHA-256 | 8bc7110e818428d0b933d50b5969f61ae51d75c50b6dabc308664dd566b2a1cb |
Recovered source transcript
Download complete source text ↓25 lines · 0.9 KB
// Define the number of lottery balls and the maximum value of each ball
const numBalls = 10
const maxBallValue = 100;
// Initialize an array to hold the lottery numbers
const lotteryNumbers = []; //This is an array
// Generate the lottery numbers this is the for loop that is needed to generate the numbers this can also be considered a method
for (let i = 0; i < numBalls; i++) {
let ballValue = Math.floor(Math.random() * maxBallValue) + 1;
// Check if the generated number has already been picked. Also can be considered a method
while (lotteryNumbers.includes(ballValue)) {
ballValue = Math.floor(Math.random() * maxBallValue) + 1;
}
// Add the unique ball value to the lottery numbers array
lotteryNumbers.push(ballValue);
}
// Sort the lottery numbers in ascending order
lotteryNumbers.sort((a, b) => a - b);
// Print the lottery numbers
console.log(`The winning lottery numbers are: ${lotteryNumbers.join(', ')}`);