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


Sarah Breidenbach
Sarah Breidenbach
4,490 Points

Why does JSHint give me these warnings about ES6?

Here is my code

document.addEventListener('DOMContentLoaded', () => {

    const anchor = document.getElementById("sarah-email");
    const username = "sarahbwebdev";
    const hostname = "gmail.com";
    const urltext = username + "@" + hostname;
    const mail = "mailto:";
    const url = mail + urltext;
    anchor.href = url;
    const fontName = " 'Cairo' ";
    const startSpan = '<span style="font-family:';
    const endSpan = ', serif;">@</span>';
    const visibleAddress = username + startSpan + fontName + endSpan + hostname;
    anchor.innerHTML = visibleAddress;


JSHint warnings:

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

What does this mean? Am I doing something wrong?

And if there are any other unrelated problems with this code please let me know.

1 Answer

Steven Parker
Steven Parker
229,921 Points

By default, JSHint gives you warnings if you use new ES6 features that might not run on systems that don't support them. There are two ways to silence those warnings:

  1. If you click "CONFIGURE" you can click to turn on the checkbox next to "New JavaScript features (ES6)".
  2. You can add a comment line like this at the top of your file:
// jshint esversion: 6