The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Store JSON data in a variable Reply To: Store JSON data in a variable


Most likely reason is to make the data easy to maintain — e.g., adding or removing questions is easier if they are organized in a simple format, separately from the actual application code. (To clarify, note that, strictly speaking, the questions and answers aren’t “code”: they’re data.)

Reading about “separation of concerns” might be helpful as well. It might be difficult to see the advantage with such a small project, but it certainly is a habit worth developing.