Function in one js file can't find the js file in another?


I have the following code in one js file:

    function check_holiday (dt_date){
	var holidays = {
	    var hol_array = holidays[dt_date.getFullYear()];
	    if( hol_array ){
		var is_hol = false;
		for( var i in hol_array ){
		    var hol = hol_array[i];
		    if( ( hol[0] == dt_date.getMonth()+1 && hol[1] == dt_date.getDate()) || ( dt_date.getDay() == 0 || dt_date.getDay() == 6 ) ) // Skip weekends
			    is_hol = true;
		if( !is_hol ){
	return dt_date;

Open in new window

and i'm calling it in another js file:

var futureDate = check_holiday(date_time);

Open in new window

I see the following error in Firebug:
error from Firebug in Firefox
Hope you can help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
have you referenced the files in your source code in the right order?
First the file with the function and then the second file where you call it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ACEAFTYAuthor Commented:
Yes I have one.js in the header and two.js inserted at the bottom of the body tag.
Rainer JeschorCommented:
as this works, it must be something either in one of your JS files or in the HTML file.
Could you please attach the three files?
Do you use any namespace in one.js?
Rainer JeschorCommented:
And here my local sample which runs on my test IIS site successfully.

Whats your web server? Are you using any server side code (PHP, ASP, ASP.NET ...)?
ACEAFTYAuthor Commented:
As I was getting the files ready to send to you and I reallised the problem. The one.js had

var $ = jQuery.noConflict();      

and the function was within this, so wasn't accessible globally. I didn't see because it wasn't at the beginning of the document as you'd expect it to be.

Technically your answer is correct you i'll accept your solutions.

Thank you for the time to trying to help me.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.