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 trialElena Man
21,092 PointsCompleting the requirement with JS instead of PHP
Could someone please explain to me why this particular problem is best solved with JS instead of a backend language like PHP?
For example, PHP could check the database to see if the employee is in the office or not and then output the HTML code accordingly. Why is JS needed in this case?
3 Answers
Steven Parker
231,248 PointsIn many cases, the front-end developer has no access to the back-end programming. But code in JS generally runs in the browser, so it can be used to create front-end solutions that would work in all cases.
Mike Straw
7,100 PointsOne thing that could be done with JS is to allow for a real-time update of the employees' statuses. So for example, if John goes out to lunch, his status would change to "Out". If the JS made an AJAX call periodically (say, every 30 seconds), then the sidebar could be changed on the fly while someone is still reading whatever page they're viewing instead of seeing it the next time they go to another page.
Samuel Almanza
4,725 PointsIs it possible now to use Full-Stack JavaScript and use Node + Express for the back-end scripting? I know the MERN stack has gained more popularity in recent years.
Steven Parker
231,248 PointsYes, Node is specifically a JavaScript engine for running code in the back end, and Express is a framework for creating Node applications.