Skip to content

Instantly share code, notes, and snippets.

@bwreid
Forked from rogerwschmidt/functions.md
Last active September 11, 2018 17:14
Show Gist options
  • Save bwreid/61a00628549cdb2731463594efbc22ca to your computer and use it in GitHub Desktop.
Save bwreid/61a00628549cdb2731463594efbc22ca to your computer and use it in GitHub Desktop.

Functions

Objectives

  • Define what an abstractions is
  • Explain why abstractions are useful
  • Define what a function is and why they are useful
  • Explain the syntax of functions
  • Describe why functions are abstractions

Guiding Questions

  • What are abstractions? With your table, create a definition of what an abstraction is. Also, describe one abstraction that you have worked with.

    Your answer...

  • Why are abstraction useful? With your table, synthesize an explanation of why abstractions are useful. Add an example of when an abstraction helped you be more productive.

    Your answer...

  • Define what a function is and why they are useful.

    Your answer...

  • Explain the syntax of a function.

    Your answer...

  • Why are functions abstractions?

    Your answer...

  • Update the following code to use a function.

    var names = [ 'Erik', 'Sarah', 'Nancy', 'Matt' ]
    if (names.length > 0) {
      var selected = names.shift()
      console.log(selected)
    }
    if (names.length > 0) {
      var selected = names.shift()
      console.log(selected)
    }
    if (names.length > 0) {
      var selected = names.shift()
      console.log(selected)
    }

    Your answer...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment