Why is it the way it is?

Tell us what’s happening:
Describe your issue in detail here.

So it’s not so much a problem with the code. that part I have. It’s more of a why its formatted the way it is.

Why does the function have () at the end of it before {}? what is the purpose of it? I get function reusableFunction, but why does the rest of it belong there?

  **Your code so far**

function reusableFunction() {
console.log("Hi World");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Challenge: Write Reusable JavaScript with Functions

Link to the challenge:

The parens are where you pass in arguments to the function. This function doesn’t have any so the parens are empty. But let’s say you wanted to modify the function so it said hello to someone:

function reusablefunction(name) {
  console.log(`Hello ${name}`);

Now you can call it as:


Okay, thank you that makes so much more sense now. I was very confused wondering what went inside the paren.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.