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 trialDaniel McHugh
1,821 PointsArrow syntax not working?
This code from the video is not working when I use arrow syntax to replace the function. What am I doing wrong? Here's the screenshot: https://w.trhou.se/jqd9s1k8rw It works perfectly when I replace it with a normal function.
Jennifer Nordell
Treehouse TeacherHi there! Thanks for including the link to your workspace so that we can see your code. I'm a bit curious as to what browser and what version of the browser you're using. When I fork your workspace and replace the normal function with an arrow syntax function, it works for me. So I'm wondering if it's supported in your browser.
That being said, it would be nice if you had left the arrow syntax that you tried in instead of the function that does actually work so that we can rule out errors there.
Daniel McHugh
1,821 PointsHere is an updated screenshot: https://w.trhou.se/ek2eiidvkn
and here is the code: const myHeading = document.getElementById("myHeading"); const myButton = document.getElementById("myButton"); const myTextInput = document.getElementById("myTextInput");
myButton.addEventListener("click", () => { myHeading.style.color = 'red'; });
Jennifer Nordell
Treehouse TeacherHi again, Daniel! I just forked the new one and there's good news and bad news. The good news is that it works on my end.! I click the button and the headline changes to red. But the bad news is that I still don't know why you're not seeing what I'm seeing. So once again, what browser are you using and what version? Because it may very well be that you're using a browser where arrow syntax simply isn't supported.
Martin Zarate
10,723 PointsAs Jennifer said, it works correctly for me too, I am using the latest Google Chrome. Cheers.
Daniel McHugh
1,821 PointsOkay, thanks everyone. I'm at work using IE 11 since it's the only browser available. I'll just write it out the long way while I'm using this browser.
1 Answer
Steven Parker
231,198 PointsThe browser is the issue. According to Can I Use?, IE 11 does not support arrow functions.
Martin Zarate
10,723 PointsMartin Zarate
10,723 PointsWe can't see your code.