Files

30 lines
823 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Write Reusable JavaScript with Functions
---
# Write Reusable JavaScript with Functions
2018-10-12 15:37:13 -04:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
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
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```javascript
function reusableFunction() {
console.log("Hi World");
2018-10-12 15:37:13 -04:00
}
```
</details>