Skip to content

Evelyn Weather API#208

Open
EvelynBell wants to merge 2 commits into
projectshft:masterfrom
EvelynBell:master
Open

Evelyn Weather API#208
EvelynBell wants to merge 2 commits into
projectshft:masterfrom
EvelynBell:master

Conversation

@EvelynBell
Copy link
Copy Markdown

No description provided.

Comment thread main.js
const currentDate = new Date();

document.getElementById('submit-search').addEventListener('click', function () {
cityName = document.getElementById('location').value;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch for definition if its const or let

Comment thread main.js
const daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const currentDate = new Date();

document.getElementById('submit-search').addEventListener('click', function () {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrow function next time =)

Comment thread main.js
fetch(fetchUrl, {
method: 'GET',
dataType: 'json'
}).then(data => data.json()).then(data => readWeatherData(data, city));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know how to use arrow function :)

Comment thread main.js
fetch(fetchUrl, {
method: 'GET',
dataType: 'json'
}).then(data => data.json()).then(data => readWeatherData(data, city));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data is too generic, consider using something specific like weatherData

Suggested change
}).then(data => data.json()).then(data => readWeatherData(data, city));
}).then(weatherData => weatherData.json()).then(jsonWeatherData => readWeatherData(jsonWeatherData, city));

Comment thread main.js
const readWeatherData = function (data, city) {
const weatherData = [];

for(let i = 0; i < data.list.length; i += 8) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a great opportunity to use an array helper method like forEach or map

Comment thread main.js
const currentWeatherData = data.list[i];

const weather = {
temp: ((currentWeatherData.main.temp - 273.15) * (9/5) + 32),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for readability, the calculation should have been in a function

Comment thread main.js Outdated
weatherData.push(weather);
}

console.log(weatherData);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove logs

Comment thread main.js
Comment on lines +46 to +49
if(document.querySelector('.main-weather').hasChildNodes() && document.querySelector('.sub-weather').hasChildNodes()) {
document.querySelector('.main-weather').replaceChildren();
document.querySelector('.sub-weather').replaceChildren();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for readability, move to a function clearCurrentWeatherDisplay() or something like this

Comment thread main.js Outdated
</div>
</div>`;

if(i != 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(i != 0) {
if (i != 0) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants