-3

When you normally wish to add a js script from a subfolder, you use: <script src=foldername/filename.js></script>

I have a specific local folder that's called jsfiles and it's placed within the same folder level as the main script calling it. But there are an unspecified number of js files with unknown names, each having one JSON files as arrays defined in it.

All files look like: var json = [{...},{...}]

How do I set up a for loop to push EACH json object in EVERY file in the jsfiles into an array, although I don't know the names to the files?

Or do I need another programming language than JavaScript for that matter?

Thanks in advance.

Doruk Karınca
  • 195
  • 1
  • 12

1 Answers1

0

Get all the files in an array

Then:

jsArray.forEach(function(j) {
  $('head').append('<script src="...." type="..."');
});
Community
  • 1
  • 1
Teo
  • 614
  • 1
  • 4
  • 13
  • It's better to include the code from mentioned question in your answer. In case that question will deleted and your link become irrelevant. – Ilya Luzyanin Sep 11 '14 at 15:01