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

jax taylor
seal-mask
.a{fill-rule:evenodd;}techdegree
jax taylor
Full Stack JavaScript Techdegree Student 13,166 Points

This wont work for me. Console throws error: recentSearches.forEach is not a function. (line 85) index.html

I don't have nodemon module installed in my textEditor, but it tried launching in workspace as well. neither work and both throw the same error: (index):85 Uncaught TypeError: recentSearches.forEach is not a function at window.onload ((index):85)

Tried clearing localStorage to no avail

Can you post your code or a snapshot?

4 Answers

I'm having the same issue. Steps to recreate:

  1. Click Launch Workspace
  2. Click "eye" icon to view index.html in browser
  3. Type a word in the search bar and hit "search"
  4. Word does not get written to page, and there's a console error saying "Uncaught TypeError: Cannot read property 'forEach' of undefined at window.onload ((index):60)"
Andrew Bankson
seal-mask
.a{fill-rule:evenodd;}techdegree
Andrew Bankson
Front End Web Development Techdegree Student 8,625 Points

I'm having this same issue as well. As far as I can tell, I typed in all the same code that he did (so it's not the issue of those functions being undefined.) I've been messing around with it but cannot seem to find what's going wrong.

Here's a snapshot of my code: https://w.trhou.se/xveolpx613

I was having the same issue, in another question the problem was resolved by running localStorage.clear(); in the console, and it worked for me. You can try that. I hope this helped!

I opened the video workspace and without searching see the error. The following functions need to be completed as they are empty initially:

function supportsLocalStorage() {
}

function getRecentSearches() {
}

function saveSearchString() {
}

function removeSearches() {
}

Here is a workspace with the code from the finished project

https://w.trhou.se/wxtsnkzl1w