Open
Conversation
| const currentDate = new Date(); | ||
|
|
||
| document.getElementById('submit-search').addEventListener('click', function () { | ||
| cityName = document.getElementById('location').value; |
There was a problem hiding this comment.
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 () { |
| fetch(fetchUrl, { | ||
| method: 'GET', | ||
| dataType: 'json' | ||
| }).then(data => data.json()).then(data => readWeatherData(data, city)); |
There was a problem hiding this comment.
you know how to use arrow function :)
| fetch(fetchUrl, { | ||
| method: 'GET', | ||
| dataType: 'json' | ||
| }).then(data => data.json()).then(data => readWeatherData(data, city)); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
for readability, the calculation should have been in a function
main.js
Outdated
| weatherData.push(weather); | ||
| } | ||
|
|
||
| console.log(weatherData); |
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(); | ||
| } |
There was a problem hiding this comment.
for readability, move to a function clearCurrentWeatherDisplay() or something like this
main.js
Outdated
| </div> | ||
| </div>`; | ||
|
|
||
| if(i != 0) { |
There was a problem hiding this comment.
Suggested change
| if(i != 0) { | |
| if (i != 0) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.