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 Treehouse Club: JavaScript Car Sounds What's JavaScript?

Théo Leimer
Théo Leimer
2,103 Points

Hey, I was confused on what the () was used for in a javascript function like function startcar()

Can anyone clarify this for me?

1 Answer

Theo VOGLIMACCI
Theo VOGLIMACCI
8,027 Points

Hello Théo!

That's just how we declare a function in javascript. When you'll built more complex ones, you'll place the arguments inside the parentheses.

function addTwoNumbers(a, b) {
let result = a + b;
return result;
}

When you'll call the function you'll write

addTwoNumbers(3,4)

and it will return you 7 ;-)

In this case, there are no arguments in the function so we type nothing in it!

That's just that simple.

Nice response Theo. I just also want to say to the OP that this course is really just an introductory course to some of the aspects of Web Development. This is a great start for any newbie as it covers some networking, web-based development & whatever else is yet to come.

That being said, when you cover a Javascript module on Treehouse that is 6-8 hours long you'll definitely learn of passing parameters (As Theo has demonstrated above), functions & a whole lot more in great detail.