This is a really awesome project — the code is well written and the story elements are super fun!
One big technical issue 
On lines 78 and 79, you get random numbers based on the length of the firstNames
and lastNames
arrays plus one. The result of this is that there is a chance the indices passed in to create charName
on line 81 could be outside the bounds of the array. In the screenshot below, note that the last name is undefined
:
Let’s look at why.
firstNames
has a length
of 40
, so on line 78 we evaluate Math.floor(Math.random() * 41)
since we add 1 to the length. Math.random()
generates a random decimal value between 0 (inclusive) and 1 (exclusive). Multiplied by 41, we can expect a decimal value between 0 (inclusive) and 41 (exclusive), so 0-40.9999…
Math.floor()
will then round the value returned by Math.random()
down to the nearest integer. This makes the possible values of numOne
on line 78 any integers between 0 and 40, both inclusive. Since the length of the array is 40, its valid indices are integers 0 through 39 — if numOne
ends up being 40, it goes out of the bounds of the array and returns undefined
!
Since only one index is out of range, you can resolve this by just using .length
instead of .length + 1
on each affected line (78, 79, 123).
My only other suggestion would be to create template functions for generating random numbers. Already within this code, there are several instances of Math.floor(Math.random() * number)
. I imagine generating random numbers will continue to be a common occurrence as you work on this project.
You could cut out some of that repetitive typing (i.e. chances for typos) by writing a function like this:
const getRandomInt(multiplier) {
const randomInt = Math.floor(Math.random() * multiplier);
return randomInt;
}
Then, the call on line 5 could be rewritten as
let luck = getRandomInt(51);
You could also define a similar function to wrap the construction on line 19, Math.floor(((1.4 * strength) + luck));
since that is reused several times as well.
Keep up the great work, happy coding! 