Passed
Push — master ( 09a54a...cba1d2 )
by Muhammad Dyas
01:26
created

src/helpers/utils.js   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 7
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
mnd 1
bc 1
fnc 1
dl 0
loc 7
rs 10
bpm 1
cpm 2
noi 3
c 0
b 0
f 0
1
2
/**
3
 * @param {array} names - list of names
4
 * @param {integer} winnerCount - total winner that picked from names
5
 * @returns {array} - list of winner
6
 */
7
export function getRandomWinners(names, winnerCount = 1) {
8
  for (let i = names.length - 1; i > 0; i--) {
9
    const j = Math.floor(Math.random() * (i + 1));
10
    [names[i], names[j]] = [names[j], names[i]];
0 ignored issues
show
Bug introduced by
The variable j seems to be never declared. If this is a global, consider adding a /** global: j */ comment.

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.

Loading history...
Bug introduced by
The variable i seems to be never declared. If this is a global, consider adding a /** global: i */ comment.

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.

Loading history...
Bug introduced by
The variable names seems to be never declared. If this is a global, consider adding a /** global: names */ comment.

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.

Loading history...
11
  }
12
  return names.slice(0, winnerCount);
13
}
14