JavaScript JavaScript and the DOM Getting a Handle on the DOM A Simple Example

Daniel McFarlin
Daniel McFarlin
5,168 Points

I got 2 questions

First, can someone please tell me why this code isn't working? I have redone it 3 times now, still not changing of heading color to red when click on. :(

https://w.trhou.se/ffl2g2xnvq

Also does anyone have issues with workspaces randomly indenting when you press enter to go to the next line? and I don't mean like one tap over it indents to like 3/4 across the page to the right...sooooo frustrating when it does that. Is there a setting somewhere in workspaces that I don't know about?

Please help! Thanks friends

2 Answers

Jennifer Nordell
MOD
Jennifer Nordell
Treehouse Moderator

Hi there! You're doing great, but you have a typo which is preventing the code from working as a syntax error is occurring. You have typed

myHeading.addEventListner

But you meant to type:

myHeading.addEventListener

Note the spelling of "Listener". As for the indentation problem, I've run into this once or twice, but generally it's because I haven't properly closed something off in the line before so the editor believes it should do that. As an alternative, you could just type it up in a text editor and paste it in, if you like.

Hope this helps! :sparkles:

Daniel McFarlin
Daniel McFarlin
5,168 Points

Jennifer Nordell, you just may be my favorite person ever for pointing out what I apparently did 3 times while doing this code segment. Thank you SOOOOO much. Also glad to hear it is not just me having issues when it comes to the indention from time to time as well.

Another thing I haven't wrapped my head around in this bit of code is the arrow function. " => " I think I need to do some more research on what exactly that means and what it does.

Jennifer Nordell
Jennifer Nordell
Treehouse Moderator

Daniel McFarlin about that =>... luckily you don't have to look far! Treehouse has an 8 minute workshop specifically on Arrow Function Syntax. If you've got 8 minutes to spare, you can clear it up pretty quickly :smiley:

Clayton Perszyk
MOD
Clayton Perszyk
Treehouse Moderator 45,753 Points

Hey Daniel,

With regards to your first question, you need to change addEventListner to addEventListener. Just missing an 'e'.

As for your second question, I'm afraid I can't help; I don't really have any experience with workspaces. Sorry.

Best,

Clayton

Daniel McFarlin
Daniel McFarlin
5,168 Points

Thank You Clayton! Do you know where I can find some more info explaining the arrow "=>" function though? I don't quite understand that yet.