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 Project Overview

My solution for the weather command line application

Hi guys, I coded the weather command line application using Open Weather Map API. At first, the user enters the city name and country code to the application. Then, the application searches for the city id which related to the city name and country code. Then, it fetches the current temperature in Fahrenheit of the entered city by using its id and displays that temperature to the user.

Please give your opinions about my code to help me to improve it. Thanks in advance.

My code: https://w.trhou.se/pm5hgr98ac

To learn more about how to get the current weather data using Open Weather Map API: https://openweathermap.org/current

To get the API key: https://openweathermap.org/appid

Official Site: https://openweathermap.org/

Andrew Chalkley Sir, can you give your opinion about my code, please?

Steven Parker
Steven Parker
230,274 Points

FYI, Andrew Chalkley has moved on to other opportunities and is no longer on staff at Treehouse.
But he tweets a lot.

Oh thanks for notifying me Steven Parker. Can you give me your opinion about my code, please?

1 Answer

Steven Parker
Steven Parker
230,274 Points

At first glance the p;rogram seems well constructed, and good job on not accidentally sharing your API key (a common mistake)! :+1:

One slight enhancement might be to use a character entity to add a degree symbol to your output:

    console.log(`The current temperature in ${weather.name} is ${weather.main.temp}°F`);

Thank you so much for the feedback Steven Parker.

Steven Parker
Steven Parker
230,274 Points

Oops, I was too hasty, the character entity won't work for console.log. I was thinking the message was going to the page (document.write).

Ahh no it's a command line application. Are there any options to include character entities in command line print options like console.log()? Steven Parker

Steven Parker
Steven Parker
230,274 Points

Character entities only work on rendered HTML. But you might be able to just include symbolic characters in your string.

Here's the rendered degree symbol, try pasting it into your code and see if it's visible in the output: :point_right: °