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
kerri schiff
1,989 Pointsapp.js?ver=4.2.5:13 Uncaught SyntaxError: Unexpected token }
I'm trying to work through the "wordpress theme development" tutorial - I'm on the navigation section. When I click on the menu icon nothing happens - I get this error message from the inspect elements section:
app.js?ver=4.2.5:13 Uncaught SyntaxError: Unexpected token }
and when I go to the app.js page i get this error:
line 3: Missing "use strict" statement.
If you can help me solve this I would be forever grateful.
kerri schiff
1,989 Pointsthis is what the errot code looks like:
Uncaught SyntaxError: Unexpected token } app.js?ver=4.2.5:13
this is the code for the app.js code:
jQuery(document).ready(function($) {
$(document).foundation();
$( ".nav-toggle" ).click(function() {
$(this).toggleClass("open");
$("nav").fadeToggle(100);
return false;
});
});
error says thee problem is on line 3
3 Answers
jobbol
Full Stack JavaScript Techdegree Student 19,117 PointsAdd this to the top of your Javascript and it should work.
"use strict";
kerri schiff
1,989 PointsUnfortunately this did not work - and I got an additional error message saying:
Use the function form of "use scrict."
I am totally new to writing code so none of this means anything to me.
kerri schiff
1,989 PointsUnfortunately this did not work - and I got an additional error message saying:
Use the funtion form of "use scrict."
I am totally new to writing code so none of this means anything to me. Please help.
Perhaps I'm over my head with designing my own wordpress theme...? That's what I really wany help with. Can anyone help with that?
jobbol
Full Stack JavaScript Techdegree Student 19,117 PointsIt's not as hard as you're making it seem. You just need to do more research for these problems on your own. I just googled your error, and the first result gave the answer.
Wrap all the code in a self invoking function, and add the strict statement to the top like this.
(function(){
"use strict";
//all the code goes in here.
})()
kerri schiff
1,989 Pointsunfortunately it's not as easy as you're making it seem. I will do some research on my own to get the menu icon to open, but so far the
Uncaught SyntaxError: Unexpected token }
message is still coming up even though I added we you suggested:
(function(){ "use strict";
jQuery(document).ready(function($) {
$(document).foundation();
$( ".nav-toggle" ).click(function() {
$(this).toggleClass("open");
$("nav").fadeToggle(100);
return false;
});
});
})();
Sam Roberton
7,225 PointsSam Roberton
7,225 PointsCould you show your code and/or link to the tutorial please.