Skip to content

Commit 34c7a6c

Browse files
authored
Update functions.js
1 parent 1b0537d commit 34c7a6c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

functions.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// returns a random integer between min (included) and max (included)
22
function randInt(min, max) {
3-
return Math.floor(Math.random() * (max - min + 1)) + min;
3+
return Math.floor(Math.random() * (max - min + 1)) + min;
44
}
55

66
// returns a random float between min (included) and max (included)
@@ -15,19 +15,19 @@ function randItem(items) {
1515

1616
// returns the number passed in with a precision number of digits after the decimal point
1717
function toPrecision(number, precision) {
18-
return +((number).toFixed(precision));
18+
return +((number).toFixed(precision));
1919
}
2020

2121
// shuffles items and returns a new array. Based on the modern Fisher-Yates shuffle algorithm
2222
function shuffleItems(items) {
23-
return items.reduce((result, item, index) => {
24-
if (index === items.length - 1) {
25-
return result;
23+
return items.reduce((result, item, index) => {
24+
if (index === items.length - 1) {
25+
return result;
2626
}
27-
28-
const jindex = Math.floor(Math.random() * (items.length - 1 - index + 1)) + index;
27+
28+
const jindex = Math.floor(Math.random() * (items.length - 1 - index + 1)) + index;
2929
[result[index], result[jindex]] = [result[jindex], result[index]];
30-
30+
3131
return result;
3232
}, items);
3333
}

0 commit comments

Comments
 (0)