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 Object-Oriented JavaScript: Part 1

Why does the Brackets text editor, which I am using instead of Sublime, give error: must use function 'use strict'?

In line 1 for both the maze and maze spaces JavaScript class, the instructor Randy Hoyt, uses notation "use strict"; and then write the individual function. I do the same on Brackets but my problem is it says error: use function for use strict? I don't know where I went wrong if all I am doing is the same thing that Randy is doing...Please help

4 Answers

Steven Parker
Steven Parker
243,318 Points

It is a "best practice" to invoke "use strict" inside closures (functions) instead of for an entire file. It sounds like your editor has elevated this from a practice to a syntax imperative.

Perhaps there is a configuration parameter you can set to prevent this enforcement, check your documentation.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I believe it might have something to do with an extension called "JSLint". JSLint tends to require the function form of the use strict; directive which means that the directive will have to be added inside each individual function.

Do i need to enable this extension then? On Brackets, it seems to use JSLint error message console to point out "use strict" is needed

Steven Parker
Steven Parker
243,318 Points

It sounds like you might want to dis‍able that extension. It seems to be giving you that error already.

Okie dokie Steven. Thanks :)

https://github.com/adobe/brackets/issues/9563 This is the site that talks about various JSLint problems. But what I want to know is that what code do I enter in brackets.json. Because in the defaultPreferences.json file, I cannot be able to change the code since it is a read only file. I was thinking if doingL

"language": { "javascript": { "linting.prefer": ["JSHint"], "linting.usePreferredOnly": true } },

would disable JSLint. So do I add this on brackets.json? Thx