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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Bob Swaney](https://uploads.teamtreehouse.com/production/profile-photos/9907902/micro_this_is_me.jpg)
Bob Swaney
13,010 PointsHow does the web server function differentiate between the home and user functions?
This may seem like a little bit of a basic question at this point, but in the following snippet,
var http = require('http');
http.createServer(function (request, response) {
router.home(request, response);
router.user(request, response);
}).listen(3000);
How does this function differentiate between the home and user function based on the URL that is entered? is it that when they put in the URL, both router functions are fired, and the URL matches one of the statements in either of the functions? or does it go to the .home method first and seeing that it doesn't match the 'if' condition, it moves on the the .user method instead if there is something after / ...being that they are two different functions themselves?
1 Answer
![Dom Ss](https://secure.gravatar.com/avatar/5be4a43d3940ac79f47e2fe26106bf1d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Dom Ss
4,339 PointsIf you are still on teamtreehouse you could see what is the order of the functions being fired by entering console.logs in every function to see which one is fired first. ;)