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 trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

Oliver Klingefjord
Oliver Klingefjord
3,525 Points

Why does he only write double parenthesises in the first question after converting to upper case (.toUpperCase)?

.toUpperCase() <--- are those parenthesis needed?

2 Answers

Ben Schroeder
Ben Schroeder
22,818 Points

Using () after a function means to execute the function and return its value. Without the parenthesis, you're just referencing the function by itself.

Think of it this way. If I were to write this:

var myName = "ben";
var uppercaseName = myName.toUpperCase();

... the value of uppercaseName would be "BEN". If you did it without parenthesis, the variable would contain the method itself, not the information you get from using that method. Try running what I wrote above in the console with and without the parenthesis; you'll see the difference when you check uppercaseName.

Joshua Bahr
Joshua Bahr
1,746 Points

Yes, they are needed. Dave's example in the video is incorrect in that the parentheses are missing for most of the questions.