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!
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
Don't understand what this is doing or why it's needed
const weather = require('./weather')
const query = process.argv.slice(2).join('').replace(' ', ''); const query2 = process.argv.slice(2);
//console logs Current temperature in Minneapolis is 40.1F Current temperature in Minneapolis is 40.1F
So I tried logging out both and they gave me the same output. What I don't understand is why .join and .replace is needed. What is it changing?
Steven Parker225,652 Points
The "replace" function is there to remove any spaces from the argument. If the argument you provide has no spaces, then it doesn't change anything. But it's there to handle any cases where a space is present in the argument.
Holy cow that was fast. Thank you Steven Parker :D