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 trialFredrik Johansson
Full Stack JavaScript Techdegree Student 12,390 PointsSharing my solution/code
//Declaring an arrow function which styles the ID "myHeading" with a red color. Putting the function in a const variable named changeColor. Since the function doesn't have any parameters I need to use parenthesis. And since there's not a multi-line I can build everything in one line.
const changeColor = () => {document.getElementById('myHeading').style.color = 'red';}
//Calling the function once the ID "myHeading" is clicked.
document.getElementById('myHeading').addEventListener('click', changeColor);
2 Answers
Johnnt Trav
Courses Plus Student 1,295 PointsLooking great but because you don't have any parameters doesn't mean you should use the arrow function. You also don't need curly braces.
This is a good read.
Piotr Manczak
Front End Web Development Techdegree Graduate 29,277 PointsWell done, keep it up!