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

JavaScript Node.js Basics 2017 Create a Command Line Weather Application Handling Errors - Solution

Swan The Human
Swan The Human
Full Stack JavaScript Techdegree Student 19,338 Points

In the zip code conditional of the weather api. Why is there parameters.zip and parameters.q?

I understand the !isNaN part and concatenating the result of the variable with ,us to make a string for the parameters depending on whether it is a zip code or a query.

My question is why is there parameters.q and parameters.zip? where are these each called? In the url i know it calls just plain old parameters. So why are the .q and .zip at the end of each?


1 Answer

Not going to use the correct terminology here but this is what I think is happening: You have a const called parameters which is an object with key value pairs.
Object parameters { units: "imperial key/property is "units" and the value is "imperial"

When they write parameters.q they are actually added a new key value pair to the parameters object the same goes for parameters.zip