A few days ago I made a lord generator for a game called Broken History I play with my mates, I started the code myself but ended up getting help with the code to finish it.
I then set about making a char gen for the same game, using the exact same methods that worked before, everything was looking good every element did what it was supposed to. However, when I got the resulting text the first time the variable curFaction was called it read undefined the second time it read the faction the user chose in the select box i.e. Saxathia. The variable is assigned in the $(document).ready() function so in theory is should be assigned before it is called right?
I can’t think why this happens, the variable is called as part of an array does that make any difference?

Here is the jsLint http://jsfiddle.net/CYe8J/31/
Your problem is that you are setting the character description string when the page is loaded, before the user has selected a faction.
The quickest fix is to generate the description as and when it is required. One way to do this would be to store a function in
aLevel, rather than a string, like the following:Then, when you need your description, call the function:
I’ve created a Fiddle showing this.
As an aside, your code could generally be refactored quite a lot – as a rule, if you find you are writing the same algorithm over and over again, then you need to remember the DRY principle 🙂