Local storage help on weather app

I have my code here and want to add a trashcan icon next to every fav city that comes up in the dropdown menu in case you want to remove it. How?

Have you found the trash can icon you want to use?

<i class="fas fa-trash-alt"></i>

This one. I also want to click on the favorite city and have it display. Feeling super pressured right now because it’s due tomorrow and I still need to write tests in chai and mocha.

When I reload the page, it also takes it out of the dropdown menu, but the cities are still in local storage.

Just a slight modification to your for loop which updates option’s innerHTML:

    for (let i = 0; i < favorites.cities.length; i++) {     
      option.innerHTML = `<i class="fas fa-trash-alt"></i> ${favorites.cities[i]}`

You could add event listeners to each trashcan icon and then the use a callback function which removes the element and then updates local storage’s favoriteCities property.

Since you are not creating the dropdown menu from local storage, you will have to write code to do that.

The above code you posted does not give me the icons?

Does your project have the correct library loaded to access the icon?

Edit: I have updated my post to reflect the icon you said you wanted to use. The icon I first referenced was one I used, but I added the following library to the project to use it.


I’m so pissed at this point I can’t even think straight. Any time I add a city to the local storage dropdown menu and refresh the page, they disappear even though they are in the local storage. How in the hell do I fix this and how do I set it to where if you click “Add city”, it won’t add a string or city that is already in there?

Where in your current code are you generating the dropdown menu from local storage when the page loads?

You will have to write code to make this check and not add it if the city already exists in the applicable local storage property.

I’m very very frustrated right now, I’ve kind’ve given up.

Please someone help me. I’m so frustrated my face is numb.