Conversation
adds event listeners to increase and decrease button
Wave 2 Updated partially
yangashley
left a comment
There was a problem hiding this comment.
Nice job on weather-report, team!
| ## Signatures | ||
| Laura Castro______________ Ellie A_______________ | ||
| Date: June 2, 2025_________ | ||
|
|
| @@ -0,0 +1,230 @@ | |||
| "user strict" | |||
There was a problem hiding this comment.
| "user strict" | |
| "use strict" |
| const locationURL = 'http://127.0.0.1:5000/location' | ||
| const weatherURL = 'http://127.0.0.1:5000/weather' |
There was a problem hiding this comment.
Nice job using constant variables to reference the endpoints.
| const locationURL = 'http://127.0.0.1:5000/location' | |
| const weatherURL = 'http://127.0.0.1:5000/weather' | |
| const LOCATION_URL = 'http://127.0.0.1:5000/location' | |
| const WEATHER_URL = 'http://127.0.0.1:5000/weather' |
| console.log('renderTemp temp= ', temp) | ||
| console.log('currentTemp state= ', state.currentTemp) |
There was a problem hiding this comment.
Remove debugging print statements after you're done using them to keep your project from getting bloated with code that isn't necessary to the implementation.
| console.log('renderTemp temp= ', temp) | |
| console.log('currentTemp state= ', state.currentTemp) |
| currentTemp: 70, | ||
| city: 'Seattle', | ||
| skySelect: 'cloudy' |
There was a problem hiding this comment.
As a way to further organize your project, I'd prefer that the elements that you access to make updates to the page get declared here and set all at once during page load, like we did in this example: https://github.com/Ada-Activities/Pick-Me-Up-Pup/blob/c23-solution/src/index.js#L4-L10
| // // console.log('in realtime set, before get real time', state.currentTemp) | ||
| // state.currentTemp = getRealTimeTemp(); | ||
| // temp.textContent = state.currentTemp; | ||
| // // console.log('in realtime set after real time, state of current temp', state.currentTemp) | ||
| // renderTemp(temp); | ||
| // return |
There was a problem hiding this comment.
| // // console.log('in realtime set, before get real time', state.currentTemp) | |
| // state.currentTemp = getRealTimeTemp(); | |
| // temp.textContent = state.currentTemp; | |
| // // console.log('in realtime set after real time, state of current temp', state.currentTemp) | |
| // renderTemp(temp); | |
| // return |
All commented out code that is not necessary to the implementation should be cleaned up before a PR.
At work, opening a PR for review is asking for your code to be merged into main. A team will most likely not allow any extra lines of code to be merged into main because it bloats the code base and makes it unorganized and difficult to maintain.
It can also be confusing to read this and need to figure out, why was this left in? should i uncomment it?
It could get accidentally uncommented which could result in a bug.
| // .then(response => { | ||
| // const { lat, lon } = response; | ||
| // return axios.get(weatherURL, { | ||
| // params: { | ||
| // lat: lat, | ||
| // lon: lon | ||
| // } | ||
| // }) | ||
| // }) |
There was a problem hiding this comment.
| // .then(response => { | |
| // const { lat, lon } = response; | |
| // return axios.get(weatherURL, { | |
| // params: { | |
| // lat: lat, | |
| // lon: lon | |
| // } | |
| // }) | |
| // }) |
Remove commented out code
| // Get the references to DOM elements | ||
| const inputField = document.getElementById('inputCity'); | ||
| const cityOutput = document.getElementById('city-output'); |
There was a problem hiding this comment.
It looks like these two functions are meant to run during page load because I don't see them encapsulated in a function. It's not immediately evident to me that there's code that should run on page load because it's kind of sprinkled throughout this js file.
For example, I see a stand alone function call on lines 180-181, line 207 that executes on page load.
I'd prefer a method onLoaded that executes everything required for setting the page up.
const onLoaded = () => {
registerEventHandlers();
loadControls();
};
document.addEventListener("DOMContentLoaded", onLoaded); |
|
||
| // defines small functions of event listener | ||
| const updateCityName = () => { | ||
| // cityOutput.textContent = inputFieldValue; |
There was a problem hiding this comment.
| // cityOutput.textContent = inputFieldValue; |
Delete uneccessary code
| const updateSkyDisplay = () => { | ||
| const sky = state.skySelect; | ||
|
|
||
| if (sky === 'sunny') { | ||
| skyDisplay.textContent = '☁️ ☁️ ☁️ ☀️ ☁️ ☁️'; | ||
| } else if (sky === 'cloudy') { | ||
| skyDisplay.textContent = '☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️'; | ||
| } else if (sky === 'rainy') { | ||
| skyDisplay.textContent = '🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧'; | ||
| } else if (sky === 'snowy') { | ||
| skyDisplay.textContent = '🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨'; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
Could loop through an object to set these values instead of having a lot of conditional logic here.
No description provided.