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 trialDhanuka Anushanga
13,347 PointsMy 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/
Steven Parker
231,261 PointsFYI, Andrew Chalkley has moved on to other opportunities and is no longer on staff at Treehouse.
But he tweets a lot.
Dhanuka Anushanga
13,347 PointsOh thanks for notifying me Steven Parker. Can you give me your opinion about my code, please?
1 Answer
Steven Parker
231,261 PointsAt first glance the p;rogram seems well constructed, and good job on not accidentally sharing your API key (a common mistake)!
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`);
Dhanuka Anushanga
13,347 PointsThank you so much for the feedback Steven Parker.
Steven Parker
231,261 PointsOops, 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).
Dhanuka Anushanga
13,347 PointsAhh 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
231,261 PointsCharacter 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: °
Dhanuka Anushanga
13,347 PointsDhanuka Anushanga
13,347 PointsAndrew Chalkley Sir, can you give your opinion about my code, please?