Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Trying to get Javascript to run inside <table id="loopsToRun">

https://w.trhou.se/0528wzqld6

Someone helped me here (thank you) but i got stuck along the way :-

While your code might work, I personally would use a different approach. Instead of adding the script tag inside the table, I would simply add an id attribute to the table tag. The script tag would be before the closing body tag.

The above I managed to do. Below is what I'm confused about.

With the id attribute in the table tag, you can now create a variable in the JS file and use document.getElementById to select it. Then simply call the getRandomNumber function on the variable you just created. This is just my personal opinion, I'm sure there are better ones out there.