# freeCodeCamp Challenge Guide: Write Reusable JavaScript with Functions

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [July 7, 2016, 11:36pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378 "2016-07-07T23:36:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [July 7, 2016, 11:36pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378/1 "2016-07-07T23:36:59Z")

</div>

# [Write Reusable JavaScript with Functions](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/write-reusable-javascript-with-functions)

* * *

## Problem Explanation

Functions allow you to reuse code over and over. Our task is to make a simple `reusableFunction()` that prints out “Hi World” to the console (which you can reach with **Ctrl + Shift + I** ).

You start off by using the `function` keyword, and then typing the function name (which follows Camel Case formatting). Then, type the `()`, and create the `{}` brackets. Like so:

```javascript
function reusableFunction() {}

```

Now, your function is ready to be typed in. Use the `console.log()` to print a message in the console.

* * *

## Solutions

> **Solution 1 (Click to Show/Hide)**
>
> ```javascript
> // Define the function
> function reusableFunction() {
> console.log("Hi World");
> }
> 
> // Call the function
> reusableFunction();
> 
> ```

---

<div class="post-metadata">

**Author:** ![Rifatspir](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/rifatspir/32/161557_2.png) [@Rifatspir](https://forum.freecodecamp.org/u/Rifatspir)\
**Post date:** [July 27, 2017, 9:41am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378/2 "2017-07-27T09:41:10Z")

</div>

Here’s the answer…

> function ReusableFunction() {  
> console.log(“Hi World”);  
> }  
> reusableFunction();

---

<div class="post-metadata">

**Author:** ![ADB0802](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ADB0802](https://forum.freecodecamp.org/u/ADB0802)\
**Post date:** [August 3, 2017, 2:48pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378/3 "2017-08-03T14:48:31Z")

</div>

I put that in and it returns “reusableFunction is not defined”

---

<div class="post-metadata">

**Author:** ![Rifatspir](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/rifatspir/32/161557_2.png) [@Rifatspir](https://forum.freecodecamp.org/u/Rifatspir)\
**Post date:** [August 4, 2017, 4:58am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378/4 "2017-08-04T04:58:57Z")

</div>

![](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b70f74c087b9c8209b2527bd3a054ff1eefd8fe.png)

---

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [August 10, 2019, 1:22am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378/6 "2019-08-10T01:22:28Z")

</div>

Opened on August 10, 2019, 1:22am UTC



---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 7, 2025, 12:00pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-write-reusable-javascript-with-functions/18378/7 "2025-01-07T12:00:06Z")

</div>

Closed on January 7, 2025, 12:00pm UTC


