JavaScript Node.js Basics 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
172,267 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
172,267 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
172,267 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
172,267 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: °