DEV Community

Margaret W.N
Margaret W.N

Posted on

Day 65: Bug fixes

Bug 1

I used Favicon checker to check the state of my favicon files and it was all a mess. Output from Favicon checker:
Alt Text

Alt Text

Alt Text

I initially used a smaller image, it was about 200px. That was the most likely cause of all the issues I got from the Favicon report. Fixed that by using a larger image and regenerating the manifest files. Here is the current report

Bug 2

I was using forEach() to loop through the array of weekly forecast data (from open Weather) in the displayWeeksForecast() function. The data set had an array length of 8 but I am only interested in the first six. I switched to a for loop and set the array length to 6 (data.length-2).

Bug 3

The cards created displayWeeksForecast() function were overflowing in smaller screens. I created a function to check screen width, then set the array length to 3 for small screens and 6 for larger screens. With an array length set to 3, the for loop would run thrice creating 3 forecast cards.

function checkScreenWidth(data){
    let arraylength = 0
    if (window.screen.width < 768) {
 arraylength = data.length - 5
    } else{
     arraylength = data.length - 2  
    }
    displayWeeksForecast(data, arraylength)
}

function displayWeeksForecast(data, arraylength) {
    clearPlaceholder()
    for (var i = 0; i < arraylength; i++) {
        //code to create cards and update data.
}
}
Enter fullscreen mode Exit fullscreen mode

Link to the weather app
I still have 2 more bugs to fix but I run short of time.

Day 65

Top comments (0)