Skip to content

Snow Leopards - Alaere & Anika#86

Open
Alaere00 wants to merge 17 commits intoAda-C18:mainfrom
Alaere00:main
Open

Snow Leopards - Alaere & Anika#86
Alaere00 wants to merge 17 commits intoAda-C18:mainfrom
Alaere00:main

Conversation

@Alaere00
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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.

Comment thread src/index.js
}
});

const weatherEmojisandColor = () => {
Copy link
Copy Markdown

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 thread src/index.js
Comment on lines +3 to +8
const state = {
city: 'Portland, OR',
temperature: 72,
latitude: 45.5152,
longitude: 122.6784,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread src/index.js
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)";
}
});
Copy link
Copy Markdown

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

Comment thread src/index.js
const weatherEmojisandColor = () => {
let temp = state.temperature;
let color;
if (temp <= 49) {
Copy link
Copy Markdown

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

Comment thread src/index.js
}
let tempTag = document.getElementById("tempTag");

tempTag.textContent = String(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.

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

`${state.temp}`

Comment thread src/index.js
})
.catch ((error) => {
console.log("error no temperature found");
})};
Copy link
Copy Markdown

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?

Comment thread src/index.js
nowShowingTemp();
};

const nowShowingTemp = () => {
Copy link
Copy Markdown

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