-
Notifications
You must be signed in to change notification settings - Fork 78
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
Paper - Nandita G. #56
base: main
Are you sure you want to change the base?
Conversation
…enames temperature range functions
… set to default city
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Nandita, the site looks great and it all functions. I made one minor suggestion.
Another suggestion is that the images are quite large. You might want to consider preloading the images, so the browser doesn't need to load the images AFTER you change the CSS/HTML with JavaScript.
const tempUp = (event) => { | ||
state.temp += 1; | ||
const count = document.querySelector("#tempDisplay"); | ||
count.textContent = `${state.temp}`; | ||
checkTemp(); | ||
}; | ||
|
||
const tempDown = (event) => { | ||
state.temp -= 1; | ||
const count = document.querySelector("#tempDisplay"); | ||
count.textContent = `${state.temp}`; | ||
checkTemp(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things:
- You're not using the
event
parameter so you can leave it off. - You can combine these functions
const tempUp = (event) => { | |
state.temp += 1; | |
const count = document.querySelector("#tempDisplay"); | |
count.textContent = `${state.temp}`; | |
checkTemp(); | |
}; | |
const tempDown = (event) => { | |
state.temp -= 1; | |
const count = document.querySelector("#tempDisplay"); | |
count.textContent = `${state.temp}`; | |
checkTemp(); | |
}; | |
const changeTemp = (increment) => { | |
state.temp += increment; | |
const count = document.querySelector("#tempDisplay"); | |
count.textContent = `${state.temp}`; | |
checkTemp(); | |
}; |
You can then use an anonymous function in the event registration like this:
tempDownButton.addEventListener("click", () => changeTemp( -1 ) );
No description provided.