Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Vocabulary Lesson3:11 with Joy Kesten
var - stands for variable and allows you to store pieces of data so you can use them later in your program.
return - returns a value and exits the function
for - a type of loop. A loop runs the code as many times as you've specified.
if - is a conditional statement that allows you to run a bit of code only if the conditions are correct. Otherwise it will do something else.
are often called keywords.
Don't worry about memorizing this list.
Just keep them in mind, so when you encounter a syntax error
when creating a variable, this just might be the reason.
The keyword var stands for variable.
A variable allows you to store a piece of data so
that you can use them later in your program.
Each time you create a new variable you need to use the keyword var.
This tells the browser that you're creating a new variable.
Once you create a new variable you can assign it a value.
Or not, like we did down here.
This is known as initializing a variable.
To assign a value, you put an equal sign, and then the data.
You can think about this as putting a name tag on the left and
the value on the right.
Like here, in the mash_choice function, we're gonna call this list of stuff mash.
When naming variables keep in mind,
that you shouldn't use spaces but you should use something like, CamelCase.
Like what we did down here.
CamelCase is when you capitalize,
each word after the first word to make a little bit easier to read.
I've only done this a few times, but you can see it here in randomNum.
One more thing about naming variables.
There are these things called reserved words, and a link to more information in
the teacher's notes, but you can't use any of these names when naming your variables.
If you do, your program won't work correctly.
The next most commonly used term is return.
You might also notice that the return keyword often comes at
exit the function.
Now keep in mind, any code you add after that return statement will never get run.
because it creates a loop.
This lets us do something a certain number of times.
And lastly, I wanna point out if.
If allows you to write a conditional statement into your program.
For example, if your bedroom is clean, you can have dessert.
In our program, the if statement says, if your answer doesn't equal a blank,
you're gonna add it to the end of the list.
>> That was a lot of vocabulary.
I've posted the definitions in the teacher's notes,
if you need to review before the quiz.
Once you're done, let's see how these words work in our functions.
You need to sign up for Treehouse in order to download course files.Sign up