Opentek-Org / bookquotes

Generate lines, author, and book names from people's favorite books and also inspirational quotes!
https://www.npmjs.com/package/bookquotes
MIT License
19 stars 39 forks source link

[BUG] Improper implementation of the `randomInt()` function #10

Closed gitaalekhyapaul closed 3 years ago

gitaalekhyapaul commented 3 years ago

Bug Description

The randomInt() function implemented is not valid for this use case. The function is shown below:

Screenshot_20211001_034316

As per W3Schools this generates a random number between min and max (BOTH INCLUDED), which is causing the issue.

Since both min and max can be included, the code is crashing of index out of bounds error sometimes while testing, when the randomInt() returns max. A sample screenshot is given below:

Screenshot_20211001_034241