for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
/**
* @param {array} names - list of names
* @param {integer} winnerCount - total winner that picked from names
* @returns {array} - list of winner
*/
export function getRandomWinners(names, winnerCount = 1) {
for (let i = names.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[names[i], names[j]] = [names[j], names[i]];
j
/** global: j */
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.
i
/** global: i */
names
/** global: names */
}
return names.slice(0, winnerCount);
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.