Welcome to the Treehouse Community
Looking to learn something new?
Fabio Silva5,097 Points
How does the button.onclick function know where the object dice and its method are, since they are not in the same file?
Shouldn't it be referenced by a keyword like "import"? import dice;
If we want to access the method of an object that is in a different file can we simply call it? I'm assuming these files need to be in the same folder directory? Right?
Niclas Valentiner8,947 Points
If the file containing the referred object is included prior to the reference to the object (or method/property) then it'll work.
This is because including files effectively copy pastes the entirety of that file into the DOM so it's basically putting everything together in one big 'file'.
etern Mistolo1,200 Points
<script src ="ui.js"> </script> <script src ="app.js"> </script> <script src ="jquery.js"> </script>