Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Node.js Basics 2017 Building a Command Line Application Capturing Command Line Arguments

ilovecode
ilovecode
8,070 Points

Alena Holligan's data does not always appear first

In this video Andrew says that Alena's data will always return first because she has fewer badges. But when I run the app in my console I got chalkers data first and then Alena. So I ran the app a few times and it actually does not always return first, So is his explanation still valid, as the result was not the same every time?

ilovecode-MacBook-Air:Node-Basics-2017 ilovecode$ node "app 3.js"
chalkers has 209 badges and 5991 in Javascript
alenaholligan has 135 badges and 205 in Javascript
ilovecode-MacBook-Air:Node-Basics-2017 ilovecode$ node "app 3.js"
alenaholligan has 135 badges and 205 in Javascript
chalkers has 209 badges and 5991 in Javascript
ilovecode-MacBook-Air:Node-Basics-2017 ilovecode$ node "app 3.js"
alenaholligan has 135 badges and 205 in Javascript
chalkers has 209 badges and 5991 in Javascript
ilovecode-MacBook-Air:Node-Basics-2017 ilovecode$ node "app 3.js"
chalkers has 209 badges and 5991 in Javascript
alenaholligan has 135 badges and 205 in Javascript
ilovecode-MacBook-Air:Node-Basics-2017 ilovecode$ node "app 3.js"
alenaholligan has 135 badges and 205 in Javascript
chalkers has 209 badges and 5991 in Javascript

1 Answer

Steven Parker
Steven Parker
217,443 Points

This is a great example of how asynchronous processes can't be precisely predicted. Assuming the server starts handling both requests about the same time, it makes sense that the one with less data should usually finish first, but all sorts of things can influence the speed of the individual requests.