Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snow Leopards - Alaere & Anika #86

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

Alaere00
Copy link

No description provided.

Copy link

@yangashley yangashley left a comment

Choose a reason for hiding this comment

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

Nice work on weather report, Alaere and Anika! Let me know if you have any questions.

}
});

const weatherEmojisandColor = () => {

Choose a reason for hiding this comment

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

Consider renaming this method to use a verb to indicate that this method does something, maybe something like setWeatherEmojisaAndColor

Comment on lines +3 to +8
const state = {
city: 'Portland, OR',
temperature: 72,
latitude: 45.5152,
longitude: 122.6784,
};

Choose a reason for hiding this comment

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

👍

Comment on lines +22 to +33
document.getElementById("sky").addEventListener('change', (event) => {
const bgValue = event.target.options[event.target.selectedIndex].value;
if( bgValue == 'sunny' ) {
document.body.style.backgroundImage = "url(/ada-project-docs/assets/sunshine.png)";
} else if( bgValue == "cloudy" ){
document.body.style.backgroundImage = "url(/ada-project-docs/assets/cloudy.png)";
} else if( bgValue == "rainy" ){
document.body.style.backgroundImage = "url(/ada-project-docs/assets/rain.png)";
} else if( bgValue == "snowy" ){
document.body.style.backgroundImage = "url(/ada-project-docs/assets/snow.png)";
}
});

Choose a reason for hiding this comment

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

Could this have been wrapped inside a function and the function been registered on an event inside registerEventHandlers like you do with your other event handler methods?

For example, this could be put in a method called like updateBackground and then in registerEventHandlers you could have:

const background = document.getElementById("sky");
background.addEventListener('change', updateBackground);

Doing so would ensure that your format is uniform throughout the project and makes the code a bit more readable

const weatherEmojisandColor = () => {
let temp = state.temperature;
let color;
if (temp <= 49) {

Choose a reason for hiding this comment

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

How could you refactor this method so that it's data driven instead of using several if/else if statements (maybe iterate over a data structure) ?

}
let tempTag = document.getElementById("tempTag");

tempTag.textContent = String(temp);

Choose a reason for hiding this comment

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

another way to create a string, without using the String constructor is to just use a template string

`${state.temp}`

})
.catch ((error) => {
console.log("error no temperature found");
})};

Choose a reason for hiding this comment

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

Nice work getting practice using async/await and promise with then and catch. You might see a large code base with a mix because different people are working on different parts, but usually when the project is small and we can help it we'll want to keep to one style.

Did you prefer one style over the other?

nowShowingTemp();
};

const nowShowingTemp = () => {

Choose a reason for hiding this comment

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

Consider renaming this method to use a verb, maybe something like updateNowShowingTemp

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.

3 participants