Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Local Storage Project

Local storage not saving search

Here is the snapshot, I checked the code against this workshop but I don't see any errors. Error in console is (index):81 Uncaught TypeError: recentSearches.forEach is not a function at window.onload ((index):81) https://w.trhou.se/az5r8qtzoc

I forked your snapshot, and I am not getting any console errors; everything seems to be working ok. What chain of events caused this error that you are seeing?

3 Answers

Ahhh I got it guys, I had to run a command in the console to clear the localStorage. Thanks All!

Thanks for posting your comment here because I was having the same problem with my browser. I cleared localStorage and it was finally working!

Steven Parker
Steven Parker
241,970 Points

I was also unable to replicate the issue, but I did notice the "clear" function wasn't working:

    localStorage.removeItem('removeSearches');  // you probably meant 'recentSearches' here

Thanks Haley Bengston!!