Fix bug where the randomiser would pick -1
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This was caused by the randomiser using the wrong brackets. We needed the maximum index of the length - 1, but the randomiser would take the 1 AFTER randomising, adding brackets made it do this BEFORE.
This commit is contained in:
parent
e7620ccd42
commit
e766a42235
2 changed files with 6 additions and 5 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
node_modules
|
node_modules/
|
||||||
dist
|
dist/
|
||||||
|
coverage/
|
||||||
yarn-error.log
|
yarn-error.log
|
|
@ -41,8 +41,8 @@ export default async function randomBunny(subreddit: string, sortBy?: string): P
|
||||||
return {
|
return {
|
||||||
IsSuccess: false,
|
IsSuccess: false,
|
||||||
};
|
};
|
||||||
} else if (dataWithImages.length > 1) {
|
} else {
|
||||||
random = Math.floor((Math.random() * dataWithImages.length - 1) + 0); // Between 0 and (size - 1)
|
random = Math.floor((Math.random() * (dataWithImages.length - 1)) + 0); // Between 0 and (size - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const randomSelect = dataWithImages[random];
|
const randomSelect = dataWithImages[random];
|
||||||
|
|
Loading…
Reference in a new issue