Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 5: Building an App: Clicker Game

Similar presentations


Presentation on theme: "Lesson 5: Building an App: Clicker Game"— Presentation transcript:

1 Lesson 5: Building an App: Clicker Game
UNIT 5 – LESSON 5

2 VOCABULARY ALERT: == - The equality operator (sometimes read: "equal equal") is used to compare two values, and returns a Boolean (true/false). Avoid confusion with the assignment operator "=", Global Variable - A variable whose scope is "global" to the program, it can be used and updated by any part of the code. Its global scope is typically derived from the variable being declared (created) outside of any function, object, or method. If-Statement - The common programming structure that implements "conditional statements". Local Variable - A variable with local scope is one that can only be seen, used and updated by code within the same scope. Typically this means the variable was declared (created) inside a function -- includes function parameter variables. Variable Scope - dictates what portions of the code can "see" or use a variable, typically derived from where the variable was first created. (See Global v. Local)

3 The major topic is variable scope and understanding the differences, benefits, and drawbacks, of using global versus local variables. This lesson focuses more on using global variables, since in event-driven apps that’s what you need to keep track of data across multiple events.

4 In programming, the = sign assigns something, like a value to a variable name. The == (equality symbol) COMPARES to see if the criteria listed on one side is the same as the other side. Yes or No. Boolean!

5 Variable scoping is a form of abstraction - a programming language lets you create variables with as narrow or broad a scope as you need to program a certain task. As a general practice, you usually want to create variables with the most narrow scope you can for the task at hand, since the other extreme - everything is global - can become unwieldy or hard to manage, and it doesn’t promote code reuse.

6

7 Recall In the previous lesson, we learned about the basic mechanics of working with variables in JavaScript. We developed a mental model for thinking about how values are stored and retrieved from memory and that we should read the “=” sign as “gets” to avoid confusion. Moving forward:  The whole purpose of learning about variables though is so that our apps can make use of them while a program is running. In this lesson, we’ll see how to do that. So let’s get to it.

8 This Activity Guide - The Clicker Game - Activity Guide is not strictly needed until the very end of the lesson -- it is referred to in level 21

9 Do the lesson in Code Studio
Do the lesson in Code Studio. Don’t skip anything – learning about variable global and local scope is VITAL to your programming prowess! Make the Click It game – show it to me Partner grades it with the Activity Guide Both partners sign the Activity Guide


Download ppt "Lesson 5: Building an App: Clicker Game"

Similar presentations


Ads by Google