-
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: Saejin #65
base: main
Are you sure you want to change the base?
Paper: Saejin #65
Conversation
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.
Well done Saejin, you hit the learning goals here. I left a few minor notes, but this is quite well done.
} else if (tempState.temp >= 50) { | ||
return landscape.textContent = "Grab yah coat"; | ||
} else if (tempState.temp <= 49) { | ||
return landscape.textContent = "Betta warm up the cah"; |
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.
Very.... Boston of you
const hotter = (event) => { | ||
tempState.temp +=1; | ||
temperature.textContent = `${tempState.temp}F`; | ||
temperature.style.color = tempColor(); | ||
checkLand(); | ||
landText(); | ||
}; | ||
|
||
const colder = (event) => { | ||
tempState.temp -=1; | ||
// const landscape = document.querySelector("#landscapeContainer"); | ||
temperature.textContent = `${tempState.temp}F`; | ||
temperature.style.color = tempColor(); | ||
checkLand(); | ||
landText(); | ||
}; |
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 notes:
- You're not using the
event
parameter so you can drop it. - You can combine these functions into one.
const hotter = (event) => { | |
tempState.temp +=1; | |
temperature.textContent = `${tempState.temp}F`; | |
temperature.style.color = tempColor(); | |
checkLand(); | |
landText(); | |
}; | |
const colder = (event) => { | |
tempState.temp -=1; | |
// const landscape = document.querySelector("#landscapeContainer"); | |
temperature.textContent = `${tempState.temp}F`; | |
temperature.style.color = tempColor(); | |
checkLand(); | |
landText(); | |
}; | |
const changeTemp = (increment) => { | |
tempState.temp += increment; | |
temperature.textContent = `${tempState.temp}F`; | |
temperature.style.color = tempColor(); | |
checkLand(); | |
landText(); | |
}; |
Then you can use an anonymous function to call it when you register the event handlers.
colderButton.addEventListener("click", () => changeTemp( -1 ) );
No description provided.