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 trialammarkhan
Front End Web Development Techdegree Student 21,661 PointsWhy there are variable names Song and song
Watching the video I cannot understand how and why some video have variable named song and some Songs e.g
//app.js
var hereComesTheSun = new Song
and //playlist.js
this.songs = [];
as it becomes newbie like me to understand what is being added to this
Playlist.prototype.add = function() {
this.songs.push(song)
};
1 Answer
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsSong with a capitol 'S' is a class used to instantiate one song. songs with a lower-case 's' is a local array which contains Song instances.
The best practice for remembering this is that upper-case letters at the beginning of a name means you are looking at a class and lower-case letters at the beginning of a name are for local variables.