Trouble adding JavaScript inside a custom module I’ve got a question about module development that I need some help with.

I’m building a module which needs to have multiple JS files connected to it. The first file, which has the same name as the module works just fine.
But the rest of the JS files, attached the same way are being ignored.
For example:

function mymodule_init() {
  drupal_add_js(drupal_get_path('module', 'mymodule') .'/js/mymodule.js');
  drupal_add_js(drupal_get_path('module', 'mymodule2') .'/js/mymodule2.js');
}


I’m not sure what I’m doing wrong, if anyone has a suggestion or can point me to some documentation it would be appreciated.

Thanks
Stephanie
It looks like it's due to the second implementation of drupal_get_path().

You're passing through mymodule2 as the argument, where it should just be mymodule.

e.g.

function mymodule_init() {
  drupal_add_js(drupal_get_path('module', 'mymodule') .'/js/mymodule.js');
  drupal_add_js(drupal_get_path('module', 'mymodule') .'/js/mymodule2.js');
}


On another note, if the JavaScript needs to be added on every page (as I'm guessing it does with the implementation of hook_init) then you might be better off adding your scripts in using scripts[] in the module's .info file


  scripts (Optional) 
  
  You can now add Javascript in the module's .info
  file if it should be added on every page. This allows Javascript to be
  aggregated in an optimal way, and is the preferred method of adding
  Javascript that most visitors will need on a typical site visit


Source:  Writing module .info files

References:

drupal_get_path(); API Docs

Managing JavaScript in Drupal 7

Writing module .info files