What in the Func is a Function? Quick Overview

A Block.
addTwo(2);
function addTwo(x)
{
console.log(x+ 2);
}
//4
addTwo(2);
addThree(3);
const addTwo = function(x)
{
console.log(x+2)
}
const addThree = (x)=>
{
console.log(x+3)
}
//ReferenceError: Cannot access 'addTwo' before initialization
//ReferenceError: Cannot access 'addThree' before initialization

Building a Function

//We will decalre a function, name it, and give it arguments
function exampleFunction(arg1,arg2,arg3)
{
console.log(arg1,arg2,arg3)
}
//when data is passed into the function through the parameters like-
exampleFunction("Hello ", 1)
the function with use the passed in data to perform your task
Result // Hello 1 undefined
any arguments that are left empty are defualted to undefined, and if you would like to skip an argument, you cna use the "undefined" keyword to mark the parameter as an undefined value, allowing you to input follow-on arguments.exampleFunction(undefined, undefined, "Hello")
Result // undefined undefined Hello

Returning Value

//we are going to create a function that returns a string
function myString()
{
return "hello";
}
function printString(arg1)
{
console.log(arg1);
}
//we can use our myString function to represent its return value;
printString(myString());Result // hello// or we could store the return value onto a variable
let helloString = myString();
//and then console log the string by passing the value into our //print function
printString(helloString);Result // hello
It feels relevant.

Some amazing resources

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store