Skip to content

Weather app eval submission#210

Open
colormethanh wants to merge 3 commits into
projectshft:masterfrom
colormethanh:master
Open

Weather app eval submission#210
colormethanh wants to merge 3 commits into
projectshft:masterfrom
colormethanh:master

Conversation

@colormethanh
Copy link
Copy Markdown

No description provided.

Comment thread main.js
const data = await fetchData(url);

// If location is not found
if(data.length === 0) return -1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

its better thrown an error and catch it in later.

Comment thread main.js
};

const getCurrentWeatherData = async function (lon, lat, unit="imperial") {
const returnData = {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing semi colon

Comment thread main.js

const getCurrentWeatherData = async function (lon, lat, unit="imperial") {
const returnData = {}
const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=${unit}&appid=${APIKEY}`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same

Comment thread main.js
const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=${unit}&appid=${APIKEY}`
const data = await fetchData(url);
returnData.name = data.name;
returnData.temp = data.main.temp;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if by any reason, main is not being returned, this will crash. Safer to use ?

Suggested change
returnData.temp = data.main.temp;
returnData.temp = data.main?.temp;

Comment thread main.js
const data = await fetchData(url);
returnData.name = data.name;
returnData.temp = data.main.temp;
const {description, icon} = data.weather[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
const {description, icon} = data.weather[0];
const { description, icon } = data.weather[0];

check your spacing

Comment thread main.js
const getCurrentWeatherData = async function (lon, lat, unit="imperial") {
const returnData = {}
const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=${unit}&appid=${APIKEY}`
const data = await fetchData(url);
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 and return data are very generic names, you want to use something more explicit.

Comment thread main.js
returnData.temp = data.main.temp;
const {description, icon} = data.weather[0];
const output = {...returnData, weather: description, iconCode: icon};
return output;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same as you wont call your inputs - 'input', don't call it output. Can be:
currentWeatherData same as your function.
makes sense?

Comment thread main.js
Comment on lines +58 to +60
dateArr.push(itm);
dateSeparatedArr.push(dateArr);
dateArr = [];
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 is confusing and prone to bugs. Will be hard to maintain.
A lot is being mutated here.

Comment thread main.js
Comment on lines +119 to +120
console.log("setDefaultBtn clicked");
console.log(weatherComponent.name);
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 console logs

Comment thread main.js
console.log(weatherComponent.name);
localStorage.setItem("WEATHERPROJECT", JSON.stringify({"name": weatherComponent.name}));
$("#default-city-text").text(`Default city: ${weatherComponent.name}`);
toggleModal("Success!", "New Default location has been set!");
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 can set incorrect city names as default. Should validate!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Basically, I think you need to be able to set as default ONLY if you have that city already populated with data, otherwise that button stays disabled

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