DEV Community

Margaret W.N
Margaret W.N

Posted on

1 1

Day 71: Fixed A bug!

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
    }
}
Enter fullscreen mode Exit fullscreen mode

😂 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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay