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 trialcyber voyager
8,859 PointsNeed some help.
Hello, first of all, thank you for taking the time to read this post and answer it. What I don't understand is when do we put }); and when just this }. in this code for example.
$(document).ready(function () {
$.getJSON('../data/rooms.json', function(test) {
var ul = '<ul class="rooms">';
$.each(test, function (index, rooms) {
if (rooms.available === true) {
ul += '<li class="empty">';
} else {
ul += '<li class="full">';
}
ul += rooms.room + '</li>';
});
ul += '</ul>';
$('#roomList').html(ul);
});
});
1 Answer
Steven Parker
231,269 PointsThat first one is not just a single symbol.
You have three different things there, first a close brace "}" which would end a code block started with an open brace "{", then a close parentheses ")" which would likewise end an argument list or other group of things started with an open parenthesis "(", and finally a semicolon ";" which indicates the end of a statement.
It probably just looks funny having these on a separate line and pressed together, for example this:
btn.on( "click", function () { alert("Hi"); } );
... is the same thing as this:
btn.on("click", function () {
alert("Hi");
});
That last line is the end of the anonymous function definition, the end of the argument set for "on", and the end of the statement.
cyber voyager
8,859 Pointscyber voyager
8,859 PointsAw something else I don't think you understood what I didn't know my bad, didn't explain it very well. I understand what you explained up there but what I don't understand is when we put this }); and when we put this } Now you are gonna tell me when you open an parenthesis, but in the code provided it haves for example this code:
which doesn't have an opened parenthesis, why ?
Steven Parker
231,269 PointsSteven Parker
231,269 PointsSure it does, you must have overlooked it:
cyber voyager
8,859 Pointscyber voyager
8,859 PointsHehehe thank you very much, Steve.
cyber voyager
8,859 Pointscyber voyager
8,859 PointsAlright, I will try to remember to mark my questions closed :) thanks again!