-
Notifications
You must be signed in to change notification settings - Fork 2
Challenge 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.
Here is another example:
function otherFunctionName (a, b) {
return(a + b);
}
We can call
or invoke
our function like this:
otherFunctionName(1,2);
and it will run and return its return value to us.
Learn to code and help nonprofits. Join our open source community in 15 seconds at http://freecodecamp.com
Follow our Medium blog
Follow Quincy on Quora
Follow us on Twitter
Like us on Facebook
And be sure to click the "Star" button in the upper right of this page.
New to Free Code Camp?
JS Concepts
JS Language Reference
- arguments
- Array.prototype.filter
- Array.prototype.indexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.toString
- Boolean
- for loop
- for..in loop
- for..of loop
- String.prototype.split
- String.prototype.toLowerCase
- String.prototype.toUpperCase
- undefined
Other Links