Today was an interesting day. I spent 4 hours trying to fix a bug only to discover an easier "bug-less" way at the eleventh hour. I still can decide whether to feel stupid for my previous implementation or happy I finally fixed it. Here is what I had to delete: my previous shitty code π
Current implementation:
function displayWeeksForecast(data) {
const nextDayDegree = [document.querySelectorAll('#nextDaydegree')]
const nextDayIcon = [document.querySelectorAll('#nextWeatherIcon')]
const nextforeCast = [document.querySelectorAll('#nextforeCast')]
let weeksTemp = nextDayDegree[0]
let weeksIcon = nextDayIcon[0]
let weeksForecast = nextforeCast[0]
for(i=0; i<7; i++) {
weeksTemp[i].innerText = `${Math.round(data[i].temp.day - 273.15)}Β°`;
weeksIcon[i].setAttribute('src', `https://openweathermap.org/img/wn/${data[i].weather[0].icon}.png`)
weeksForecast[i].innerText = data[i].weather[0].main
}
}
π I can barely look at my previous code with a straight face. I'm having the "who-the-hell-wrote-that" moment.
π₯To the small wins
That's it for day 71
Let's do this again tomorrow
Top comments (0)