DEV Community

Dillon
Dillon

Posted on

Learning more about functions

Functions:

  • they are declared with the funciton key word
  • then comes the name of the function
  • then the input, these are called the parameters
  • the parameters are passed into the funciton's body which is held between two {}

so here is the basic syntax

funciton dillon(this is where the parameters go!) {
console.log(what is input in the parameter);
}
dillon(4)

running the function dillon(4) would cause the console to log out 4

BIG THING - functions can access outer variables, but what happens in the function kind of stays in the function... meaning that you can't create a variable and then call it outside the function. This is what's called function scoped.

Top comments (0)