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 Create a Command Line Weather Application Retrieving Data - Solution

Brian Patterson
Brian Patterson
19,588 Points

difference between Node and Ajax.

I have two questions. What exactly does this mean?

const query = process.argv.slice(2).join("_").replace(' ', '_');

I get that we are starting from the second element in the array but I am lost as to the rest of it. Also, what's the difference between Node and Ajax? They are effectively doing the same thing with regards retrieving data from an API. So when is the right time to use which one?

2 Answers

Sorry, it's vice versa, replacing empty strings ( ' ' ) with underscores ( '_')

We are starting from the third element, not second, and then we are joining those elements on underscore, then replacing underscores with empty strings. Node is the runtime environment for JavaScript on the backend. It does not just retrieve data from API. We can do a lot of things with Node. AJAX if a front-end technology that allows us to retrieve data from some API without refreshing the page You write ajax request only in the front-end code.

Brian Patterson
Brian Patterson
19,588 Points

What do you mean β€œreplacing the underscores with empty strings.”?