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
Alexey Papin
iOS Development Techdegree Graduate 26,950 PointsWhy in my browser(s) js applications from "JavaScript Loops Arrays Objects" course works different?
I'm on course "JavaScript Loops, Arrays and Objects", doing last code challenge. No problem with that challenges, but my browser executes JavaScript code different than in video: looks like it does not shows all page until javascript executes. I've downloaded solution files made by Dave and it looks same ugly as my code: when I open index.html file in my browser (tried in Chrome and Safari) it shows prompt in endless loop until I enter "quit", but does not shows search results even when entered name exists in "students" array. So it looks like:
- Browser starts load the page
- Browser starts execute js code - nothing changes on the page
- When it finish js code ("quit entered") - it finish load page and shows last search results on it.
2 Answers
Ran ShemTov
14,148 PointsIt is best practice to use something like (on jquery for example):
$(document).ready(function(){});
and inside the function all your JS will lie down. This was you load the html entirely first, when it's ready, you do the executions.
You can also include all JS files in the bottom of the html file, so they are called after the html has been fully loaded.
If this is not the solution, you'll have to post your code for further instructions
Alexey Papin
iOS Development Techdegree Graduate 26,950 PointsYep, thanks, figured that out already )