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

Function as Parameters: my mouseover is not working.

Hello everyone, I'm having trouble figuring out what is wrong with my code. I'm trying to make the practice through the video of Function as Parameters and I'm following the code by typing my own in the workplace. I know I could easily just copy the finished code to have it right but I can't find where and why my own code isn't working properly.

Even though I have no problems with the last code snippet I typed according to the node, the node shows another error telling me something about not finding the document and I haven't even touched that part of the original code.

"treehouse:~/workspace$ node app.js
/home/treehouse/workspace/app.js:1
(function (exports, require, module, __filename, __dirname) { const toggleList = document.ge tElementById('toggleList');
^

ReferenceError: document is not defined "

Here is my Snapshot: https://w.trhou.se/jo6qkxaut3

If anyone could help me with it I would be glad! TYA.

1 Answer

Steven Parker
Steven Parker
231,007 Points

The DOM, and the associated "document" object, is a web browser component.

Since node.js runs on the server, it does not have a built-in document object, nor would it have any associated HTML code to define elements that you might select with a method like "getElementById". It sounds like the exercise you are working with is intended to be run in a browser instead of node.js.

Even when run on browser it doesn't show the changes when I pass my mouse over the words, I feel like there is a typo somewhere but I cannot find it.

NVM, just found the error. Thank you for the reply!