Mystery Box
// Define an array of collections const collections = ['Collection A', 'Collection B', 'Collection C']; // Function to generate a random mystery box code function generateMysteryBoxCode() { // Generate a random integer between 0 and the length of the collections array const randomIndex = Math.floor(Math.random() * collections.length); // Use the random index to select a collection const collection = collections[randomIndex]; // Generate a random 4-digit code const code = Math.floor(Math.random() * 9000) + 1000; // Return the code and the associated collection return `${collection} - ${code}`; } // Add a click event listener to the "Draw" button document.getElementById('draw-btn').addEventListener('click', function() { // Generate a mystery box code const mysteryBoxCode = generateMysteryBoxCode(); // Display the code in the "mystery-box" paragraph element document.getElementById('mystery-box').textContent = mysteryBoxCode; });
Your title
// Define an array of collections
const collections = ['Collection A', 'Collection B', 'Collection C'];
// Function to generate a random mystery box code
function generateMysteryBoxCode() {
// Generate a random integer between 0 and the length of the collections array
const randomIndex = Math.floor(Math.random() * collections.length);
// Use the random index to select a collection
const collection = collections[randomIndex];
// Generate a random 4-digit code
const code = Math.floor(Math.random() * 9000) + 1000;
// Return the code and the associated collection
return `${collection} - ${code}`;
}
// Add a click event listener to the "Draw" button
document.getElementById('draw-btn').addEventListener('click', function() {
// Generate a mystery box code
const mysteryBoxCode = generateMysteryBoxCode();
// Display the code in the "mystery-box" paragraph element
document.getElementById('mystery-box').textContent = mysteryBoxCode;
});
Featured Rings
Save 31%


Stylish Star Women Drop Earrings Shiny White Zircon Exquisite Versatile ~ 24 days Delivery estimate
Sale price$9.95
Regular price$14.33


Classic Elegant Simulated-pearl Tassel Long Crystal Earrings
Sale price$19.99


925 Sterling Silver Green Gold Hoop Earrings
Sale priceFrom $12.00


Halloween glow-in-the-dark flower bracelet
Sale price$6.99


Europe And America Halloween Bat Spider Web Bracelet
Sale price$6.99

Hot Selling Rings European And American Simple Halloween
Sale price$6.99


Halloween Earrings Smiley Pumpkin Earrings
Sale price$5.50
Save 5%


Women's Earrings Set Pearl ~ 24 days Delivery estimate
Sale priceFrom $19.99
Regular price$21.00