Skip to content

Instantly share code, notes, and snippets.

@Shurlow
Forked from rogerwschmidt/Day5.md
Last active May 15, 2017 23:06
Show Gist options
  • Save Shurlow/a180827ddc715932eb8f2a6bb377a6cb to your computer and use it in GitHub Desktop.
Save Shurlow/a180827ddc715932eb8f2a6bb377a6cb to your computer and use it in GitHub Desktop.

Functions

Objectives

Describe the anatomy of a function definition.

Turn and speak with your neighbor, define and describe each of the parts of the following function

function createGreeting(name){
  var greeting = 'Hello ' + name + '!';
  return greeting;
}
Come up with your own real-world analogy for a function JavaScript.

Articulate the difference between defining and invoking a function.

What is the difference between a function definition and a function invocation?

Create functions with named parameters, and pass in arguments when calling them.

Create a function with 2 parameters that returns the sum of the parameters.
Then invoke the function with the arguments 4 and 5 as numbers.

Control a for loop inside a function using an argument to determine the looping condition.

Create a function that takes a number as a parameter, print the string "I'm in a function"
as many times as the number specifies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment