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 jQuery Basics Working with jQuery Collections Adding/Removing Classes

I get a strict mode error for my code below about a global variable?

My code to answer the task is as follows;

$submit=$(".submit-btn"); $submit.attr("disabled");

I get an error saying that strict mode prevents creation of a global variable which is $submit.

Is strict mode turned on in the treehouse environment? Is this something I can turn off I do I need to write my code differently?

1 Answer

Heidi Fryzell
seal-mask
MOD
.a{fill-rule:evenodd;}techdegree seal-36
Heidi Fryzell
Front End Web Development Treehouse Moderator 25,178 Points

Hi James,

There are a couple things I am noticing in your code. I think you want to use "const" to declare the variable, const will declare that variable and prevent it from being re-assigned, which is a good thing because you always want the variable to just select the class on the button and not change, like this:

const $submit = $('.submit-btn');

And you need to flag the "disabled" attribute as "true", like this:

$submit.attr("disabled", true);

Hope this helps! Heidi