Write Reusable JavaScript with Functions
In JavaScript, we can divide up our code into reusable parts called functions.
Here's an example of a function:
function functionName() {
console.log("Hello World");
}
You can call or invoke this function by using its name followed by parentheses, like this: functionName();
Each time the function is called it will print out the message Hello World
on the dev console. All of the code between the curly braces will be executed every time the function is called.
-
Create a function called
reusableFunction
which prints the stringHi World
to the dev console. - Call the function.
Tests
- Waiting: 1.
reusableFunction
should be a function. - Waiting: 2. If
reusableFunction
is called, it should output the stringHi World
to the console. - Waiting: 3. You should call
reusableFunction
once it is defined.
/** * Your test output will go here */