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 Node.js Basics 2017 Building a Command Line Application Capturing Command Line Arguments

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
231,268 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.