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 trialasliari
4,178 PointsShort usage on function and array names "List"
Hello,
I watched all the videos so far but i feel like i did miss something.
On the HTML list example, Does Dave use "List" as a part of function and array names? Does Capital letter means that we can split this name and use to refer the long version of a function. I am very confused.
Because 2 different versions of following function works same. Does this mean that we can take the short name of function after capital letter? Using name "List" again and again is very confusing. I am looking for a connection between these names, are there any connection or they are just 3 completely different names only end with list?
function printList( playList ) {
var listHTML = "<ol>"; for ( var i=0; i < playList.length; i += 1) { listHTML += "<li>" + playList[i] + "</li>";
} listHTML += "</ol"; print(listHTML);
}
function printList( List ) {
var listHTML = "<ol>"; for ( var i=0; i < List.length; i += 1) { listHTML += "<li>" + List[i] + "</li>";
} listHTML += "</ol"; print(listHTML);
}
2 Answers
Steven Parker
231,269 PointsThese two functions are identical in performance. The parameter name is just a placeholder and it doesn't matter what it is, as long as it is used consistently inside the function.
Capital letters in a name have no functional significance other than they are considered distinct from their lower-case counterparts. For example, "myName" is a completely different identifier from "myname".
Also, those two functions both have an error on this line which they have in common:
listHTML += "</ol";
The ending tag is incomplete and should be: "</ol>"
asliari
4,178 PointsThanks a lot Steven!