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

ohboy
2,232 PointsDon'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);
weather.getData(query2) weather.getData(query);
//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?
1 Answer

Steven Parker
225,652 PointsThe "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.
ohboy
2,232 Pointsohboy
2,232 PointsHoly cow that was fast. Thank you Steven Parker :D