Basic JavaScript - Write Reusable JavaScript with Functions

function reusableFunction() {
    console.log("Hi World");
}

reusableFunction;

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Write Reusable JavaScript with Functions

Link to the challenge:

1 Like

Hi there and welcome to our community!

When you want to call a function, you must include the parentheses:

function someFunction() {
  // do something here
}

// call the function
someFunction();
2 Likes

The issue in the provided code is that you’re not actually calling the reuasableFunction. To call a function in JavaScript, you need to use parentheses () after the function name. Here’s the corrected code:

function reusableFunction() {
    console.log("Hi World");
}

reusableFunction();  // This calls the function

1 Like