Skip to content

Instantly share code, notes, and snippets.

@biglovisa
Last active May 10, 2017 02:23
Show Gist options
  • Save biglovisa/bb2fc3f2721ccfad2534dcac8e4a4aee to your computer and use it in GitHub Desktop.
Save biglovisa/bb2fc3f2721ccfad2534dcac8e4a4aee to your computer and use it in GitHub Desktop.
Functions: check-ins

Functions

Check-ins 1

  • What is a function? Give an example of a daily task which could be abstracted into a function.
  • In your console, create a named function and an anonymous function.
  • Create a function called myFunctionName. What does myFunctionName return? What does myFunctionName() return?
  • What does a function return by default?
  • Create a function which returns "You are the world's greatest" when invoked.

Check-ins 2

  • What part is the function signature of the following function: function calculateChanges(oldValue, newValue) { };?
  • Given the function: function makeACake(ingredients, servings, isPerishable)
    • If I invoke the function like this makeACake(45, 12, 98), what will be the value of ingredients, servings, and isPerishable in the function body?
    • What about this: makeACake("sugar, egg, flower", 12)?
    • What about this: makeACake(true, 3)?
  • Create a function with one parameter. How would you access the argument within the function without using the parameter name?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment