Week 3: Functions and Scope
Main Objective: Learn to create our own abstractions to organize larger and more complex programs.
Lessons:
Project:
Follow the project instructions as best you can. You can ask for help from your team or the tutors, if needed, but make sure you're submitting your own work.
Assessment:
Go to your cset
repo on GitHub and create a new file in the 105
folder called assessment-3.md
. Add your answers to the following questions to the file and "commit" them to GitHub. Here are the guidelines if you forget them.
- How do you feel about the pace of the program so far? Is it too slow? Too fast? Or just right?
- Why do you think functions are a useful tool to organize large programs?
- In class, we've been using the analogy of a zoo to explain scope. Describe the different types of scope using this analogy and provide examples using real JavaScript code.
- Quick tip: Markdown formatting creates code blocks by using backticks, just like Slack.
- Surround code with a single backtick for inline code, like
`this`
. - Or start a code block by surrounding multiple lines with three backticks, like this:
``` multiline code block ```
Reference:
- MDN Guide: Functions
- MDN Reference: Function Expressions
- Zellwk Article: Understanding Functions
- CSS Tricks Article: JavaScript Scope and Closures
- MDN Reference: String Methods
- MDN Reference: Number Methods
- MDN Reference: Math Methods
More Resources:
- Codecademy: Introduction to JavaScript
- Lesson three on Functions is good practice on the different syntaxes and returning values.
- Lesson four on Scope will help you visualize the different types of scope.
- FreeCodeCamp: Introduction to JavaScript
- The lessons "Write Reusable JavaScript with Functions" through "Counting Cards" will match this week's chapters and review some code from last week.
- This lesson uses an older version of JavaScript, so look at their unit on ES6, the version of JS we're learning. The lessons "Use Arrow Functions to Write Concise Anonymous Functions" and the next will show the new Arrow function syntax.