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
Anthony Boardman
4,672 PointsAjax and APIs Stage 4, Challenge task 3 of 3
My heads total fried! I've been on here for over eight hours so I think I need a break anyway but could anyone help me understand this question in layman's terms? I don't want you to give me the code just simplify the question :)
(Question)
Finally, to insert the temperature into the div, use jQuery's text() method. You'll need to pass the temperature into this method. The Open Weather Map API returns an object with the property main; that property holds another object with the property "temp". To access the temperature, use dot syntax, like this: weatherReport.main.temp.
My code so far:
$(document).ready(function() {
var weatherAPI = 'http://api.openweathermap.org/data/2.5/weather';
var data = {
q : "Portland,OR",
units : "metric"
};
function showWeather (weatherReport){
$("#temperature").text();
};
});
I don't want no one to give me the answer, where's the fun in that! I have most of this done. My heads just in the bin at the minute. I'm coming off here for today anyway. If someone could just simplify (dumb down) the question I would so greatfull!
1 Answer
Ken Alger
Treehouse TeacherAnthony;
You are almost there. You have accessed the id with the value of temperature. You have told it to add to it some text with jQuery's text() method. Now you just need to tell it what text to add, specifically the Open Weather Map API's temperature for the selected city.
If you are not familiar with the text() method, take a look at the documentation, but you would basically put your text inside the () of the method. Strings would be put in quotes, so text("Hello World") would output, you guessed it, Hello World. Variables can just go inside the parenthesis. I think the challenge explains how to access the temperature variable.
Does that help?
Ken