- In this video, we're going to talk about variable scope,…and how functions relate to it.…Here's an example.…I have two variables set here:…myNym is set to 32, and myResult is set to "Success!"…And then, I write a function.…It's called randomizer,…and it takes a limit as its argument.…Inside the function, I create…a variable called randomNumber,…and assign a randomly generated number to it.…Then I create another variable,…which is called myNum again, just like out here,…and I'm assigning that random number to it.…
Then down here, I'm logging a couple of lines,…and finally returning this number.…So let's execute this and see what we get.…Then we'll discuss it a little more.…So I'm going to paste this all in.…And now, I'll have a variable called myNum set to 32,…and myResult set to "Success!"…Now I'm going to invoke the randomizer function.…I'll pass in 10.…So, this is going to set myNum…to a random number between zero and 10.…Now the question is, what exactly is going to happen here?…We have a variable called myNum up here,…
- Using a text editor
- Declaring and assigning variables
- Booleans and the quest for truth
- Working with objects and arrays
- Using operators and control structures
- Iterating with loops
- Objects, references, and functions
- Promises, async, and await
Skill Level Beginner
1. Getting Started
2. Variables and Types
3. Objects, Arrays, and More
4. Operators and Control Structures
5. Iterating with Loops
7. More Advanced Pieces
Next steps3m 38s
- 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.