My big array is making my code messy

I take JS courses at FCC, still a beginner.
So I was trying to apply what I learned recently and tried making a small but silly game of my own. You get a random occupation and salary and your aim is to buy everything in the list . You can earn money by gambling (geneartes a 0 or 1 → 0 for loss , 1 for win and then the player loses or wins the amount they wagered) and by clicking a ‘work’ button which gives you a small salary.

So with this in mind I started making this, only to realise that the array which contains the items to buy was sorta large. I dont want to make it smaller by reducing the items because it isnt actually that large, it just makes the code look really MESSY.

Is there a way to put it in another file and access it from there using imports , exports or just reading json files or any other method?
If so please do explain, Thanks!

You can go straight to the source and read about it in documentation.

You could also read about it in this fcc article

Web dev simplified also has a short video explanation too

Hope that helps!

1 Like