Question

I have included moment.min.js in my page

<script src="js/jquery.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/fatcalc.js"></script>

I can call

<script>document.write(moment());</script>

and it displays the date fine on my page.

But, when I call it from within fatcalc.js

var date = moment();

I get the error:

'moment' is not defined.

Why can my html page see it, but not the fatcalc.js file?

Was it helpful?

Solution

Well, I figured it out. Seems to be some issue with Jshint I don't understand but adding this to the top of my script fixed it.

/*global moment:true */
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top