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 trialtrottly
5,394 PointsInvocation of first_name and last_name within the console.log() does not include the underscores ... ?
Why doesn't it include the underscores when invoking the variables within console.log()?
trottly
5,394 PointsThis was in a question after a video lesson:
var first_name = "John";
var last_name = "Doe";
console.log(first name + " " + last name);
// end script example
My question is why the underscore wasn't included when the variables were called as parameters for console.log ... ?
Also, what is the ( ) part of the function called? I know that parameters and arguments go inside; but is there a specific name for this part of the function?
Marcus Parsons
15,719 PointsHey Drew Bentrott,
I see exactly what you're saying. In that question, there is a typo in the invocation of console.log. It is supposed to be first_name and last_name. There have been a few other errors as well I've found with some other users, such as the logic test of null and undefined. I'm not sure if you've gotten to that yet.
The good news is, though, that this course will soon be replaced by Dave McFarland's courses JavaScript Basics and I believe JavaScript Loops, Arrays, and Objects.
Marcus Parsons
15,719 PointsOh, I also edited your comment so that it would render better on the forums. You can check out on the Markdown Cheatsheet (located just below a comment or answer box) for how I did that.
And to answer your question about () after a function call. Those () tell JavaScript that we want to execute the function right then and there. They can also hold arguments that can be passed into the function. I'm not going to confuse you too much right now, but just remember that if you put a () after a function call, it will call the function, and you can put arguments into those (). For example:
function sayHi(name) {
//Will display "Hey there, Drew!" after being called with your name in a string below
alert("Hey there, " + name + "!");
}
sayHi("Drew");
trottly
5,394 Pointsthank you, Marcus. I was beginning to count some of the typos, and I was wondering if it was just me.
Marcus Parsons
15,719 PointsNo problem, Drew! If you have any questions, we're here to help. =]
Jeremy Woodbridge
25,278 PointsJeremy Woodbridge
25,278 PointsGo ahead and post your code in a comment so we can see what you are referring to. Thank you