Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ticket draw

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 :: Html() is a JQuery Function 
Javascript :: Can Execute Backbone In RequireJS 
Javascript :: JavaScript substring when we choose negative and zero number 
Javascript :: proxy{} map in console 
Javascript :: select 2 is not working in nodejs 
Javascript :: numberformat chakra 
Javascript :: convert snake case to camelcase javascript recursive 
Javascript :: telerik grid destroy table 
Javascript :: List content on thee currentwdr 
Javascript :: FirebaseError: Unknown field filter op. 
Javascript :: mongoose lookup array of objects 
Javascript :: javascript convert color string to rgb 
Javascript :: Minimum Path Sum for loop 
Javascript :: Nested Components 
Javascript :: save for wanver dev 
Javascript :: sort an array in descending order javascript 
Javascript :: $Javascript $.get( 
Javascript :: Fetch data from multiple pages of an API in react native 
Javascript :: Uncaught TypeError: document.getElementById(...).exitFullscreen is not a function 
Javascript :: js organise string tab spaced 
Javascript :: add function 
Javascript :: javascript flow function 
Javascript :: searchable 
Javascript :: user key value within the obj js 
Javascript :: laravel data showing in single option instead of multiple option from json array 
Javascript :: dependent drop down list in jquery 
Javascript :: angularjs promise .then() to run sequentially inside a for loop 
Javascript :: Calling $http.post in batches and chaining promises 
Javascript :: npx create-create-app movie-app 
Javascript :: upsert typeorm 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =