Skip to content

Evelyn Weather API#208

Open
EvelynBell wants to merge 2 commits intoprojectshft:masterfrom
EvelynBell:master
Open

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

Conversation

@EvelynBell
Copy link

No description provided.

const currentDate = new Date();

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

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

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

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

Choose a reason for hiding this comment

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

arrow function next time =)

fetch(fetchUrl, {
method: 'GET',
dataType: 'json'
}).then(data => data.json()).then(data => readWeatherData(data, city));

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 :)

fetch(fetchUrl, {
method: 'GET',
dataType: 'json'
}).then(data => data.json()).then(data => readWeatherData(data, city));

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));

const readWeatherData = function (data, city) {
const weatherData = [];

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

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

const currentWeatherData = data.list[i];

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

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

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

console.log(weatherData);

Choose a reason for hiding this comment

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

remove logs

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();
}

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

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

if(i != 0) {

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