In this video we're going to talk about variable scope and how functions can help …us deal with it. So here's an example, I have two …variables set, my nome is set to 32, and my result is set to success. …And then I write a function. It's called randomizer and it takes a …limit as its argument. So what I'm doing here is in the …function, I create a variable also called MyNum, just like this out here. …And I'm assigning to that MyNum a random number, with this limit as an upper bound.…
So it's between zero and this limit. And then down here, I'm logging a couple …of lines, and then returning my number. So, let's execute this and see what we …get, then we'll discuss it a little bit more. …So, having pasted this in, I now have a variable called mynum, which is 32, and …my result, which is success. Now I'm going to invoke the randomizer function. …And I'm going to pass in ten. So this is going to set my num to a …random number between zero and ten. Now the question is, what's going to …happen here? We have a copy of my num up here.…
- Enabling Firebug and web inspectors
- Using a text editor
- Declaring and assigning a variable
- Booleans and the quest for truth
- Working with objects and arrays
- Using operators and control structures
- Iterating with loops
- Objects, references, and functions
- Understanding variable scope
Skill Level Beginner
Q: In "How to enable Firebug and web inspectors," at the Chrome Canary part, the author mentions going to the View menu, and then Developer. My Canary has no menu bar. The author uses a Mac, whereas I have Windows. How do I get to the same place?
A: Click the menu button at the top right of Chrome, select More Tools, and then choose Developer Tools.
1. Getting Started
Our friend, the text editor3m 35s
2. Variables and Types
3. Objects, Arrays, and More
4. Operators and Control Structures
5. Iterating with Loops
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.