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 trialmelissakeith
3,766 PointsJavascript Loops, Arrays and Objects whey is the object format in that course different from this one?
Why did we use this format for objects in that course;
var person = {
name: 'Meissa',
country: 'US',
age: '32',
treehouseStudent: true,
skills: ['JavaScript', 'Java', 'HTML']
};
but in this course we do not add the semicolon at the end of the object, like this
var calculator = {
sum: 0,
add: function(value) {
this.sum += value;
},
clear: function() {
this.sum = 0;
},
equals: function() {
return this.sum;
}
} //no semicolon here, how come?
They made a big deal about it in the intro to object literals but when making these objects we left off the semicolon?
2 Answers
Michael Hulet
47,913 PointsJavaScript is a very forgiving language, and won't complain about a lot of things, including leaving semicolons off. While your code won't crash and will run normally without semicolons, the lack of them where they're supposed to be (such as in your example) is technically a syntax error, so you should still use them
melissakeith
3,766 PointsOk thanks, makes sense.