diff --git a/.gitignore b/.gitignore index 65e3fd0..4915027 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -node_modules -dist -yarn-error.log \ No newline at end of file +node_modules/ +dist/ +coverage/ +yarn-error.log diff --git a/src/index.ts b/src/index.ts index bdd157d..400567e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,8 +41,8 @@ export default async function randomBunny(subreddit: string, sortBy?: string): P return { IsSuccess: false, }; - } else if (dataWithImages.length > 1) { - random = Math.floor((Math.random() * dataWithImages.length - 1) + 0); // Between 0 and (size - 1) + } else { + random = Math.floor((Math.random() * (dataWithImages.length - 1)) + 0); // Between 0 and (size - 1) } const randomSelect = dataWithImages[random];