JavaScript Flashcards
What arguments are required by the fetch( ) method in the ‘weather-forecast app’; what does it return as output, and what is the method that serves this output?
Mandatory resource path: url
Input element’s id: #location
API Key: apiKey
Returns a Promise: response
.then(function(response) { … }
What methods are used to update the activities list in the weather-forecast app, and what arguments do they take?
Document.querySelectorAll(‘.options div’)
.forEach(function (el) { … }
El.addEventListener(‘click’, … )
UpdateActivityList // as argument in addEventListener.
What are the state object variables in the weather-forecast app?
Condition: response.weather[0].main
Icon: “http://openweathermap.org/img/w/“ + response.weather[0].icon + “.png”
DegC: response.main.temp
City: response.name
What conditional logic is used in the updateUISuccess(response)
method to parse data into the .conditions div
?
fragment = document.createDocumentFragment( ), container = document.createElement('div');
fragment.appendChild(container);
if (document.querySelector(‘.conditions div’)) {
into.replaceChild(fragment, document.querySelector(‘.conditions div’));
}
else {
into.appendChild(fragment);
}
handleResize();
…
window.addEventListener
…
componentWillUnmount
…