Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ticket

draw(winnerCount) {
    const tickets = ["rasel", "rabina", "santo", "rajib", "billal"];
    const winnerIndexes = new Array(winnerCount);
    let winnerIndex = 0;
   if(tickets.length){
    while (winnerIndex < winnerCount) {
      const ticketIndex = Math.floor(Math.random() * tickets.length);
      if (!winnerIndexes.includes(ticketIndex)) {
        winnerIndexes[winnerIndex++] = ticketIndex;
        continue;
      }
      console.log("hi")
    }

    const winners = winnerIndexes.map((winner) => tickets[winner]);
    return winners;
   }
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: Comparing mongoose _id and strings 
Javascript :: Load RequireJS Script 
Javascript :: how to cut and paste an element in vanilla javascript 
Javascript :: codigo para salvar javascript 
Javascript :: creating a basic netsuite restlet 
Javascript :: check if a specific user is banned discord js 
Javascript :: change jquery to javascript 
Javascript :: toast.toastAlert ext js 
Javascript :: how to prevent screen tearing without vsync 
Javascript :: save input local storage react 
Javascript :: javascript Program for sum of arithmetic series using loop 
Javascript :: onclick add and remove class using jquery 
Javascript :: filtering to check that a string is contained in the object in js 
Javascript :: jsx children 
Javascript :: convert h2 to h1 jQuery 
Javascript :: starting: intent error type 3 react-native 
Javascript :: js to jsx 
Javascript :: replace methord 
Javascript :: modify an array in javascript using function method 
Javascript :: translate javascript to english 
Javascript :: metodos de arrays javascript 
Javascript :: react native pass params to previous screen 
Javascript :: utm to lat long 
Javascript :: (state.isLoggedIn = function() {return false}) react redux 
Javascript :: web3 returns an object promise instead of number 
Javascript :: Examples of correct code for the { "typeof": true } option with global declaration: 
Javascript :: Delete Button not working with json server using angularjs 
Javascript :: Wait for AngularJS Service to finish running 
Javascript :: Syntax for npx 
Javascript :: reverse array without using another array 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =