What is a script?
A script is a series of instructions that a computer can follow one-by-one
Each individual instruction in a script is also known as?
A statement - an individual instruction that a computer should follow. Each one should start on a new line and end with a semi-colon. This makes your code easier to read & follow
Each of the statements or instructions in a script should be followed by a
semicolon
what do the pink curly braces in scripts represent?
they represent the start and end of a code block. statements can be organized into code blocks. the closing curly braces isn’t followed by a semi-colon
each code block could contain more than 1 statement - true or false?
true
Is javascript case-sensitive
yes
What are some of the reasons why you should comment in your code.
What are the methods that can be used to comment in a javascript code
to explain what your code does. they help your code easier to read & understand. this can help you & others who read your code
multi-line and single-line
How to write multi-line comments
to write a comment that stretches over more than one line… /…./. Anything between these characters is not processed by the Javascript character… they are often used for descriptions of how the script works, or to prevent a section of the script from running when testing it
how to write a single-line comment
anything that follows the two forward slash characters //….. often used for short descriptions of what the code is doing
What is a variable?
A script will have to temporarily store the bits of info it needs to do its job. It can store this data in variables.
What is the #1 thing to do when using a variable?
declare the variable: announce that you want to use it - create the variable and give it a name
how to declare a variable
var name;
var = variable keyword name = variable name (in order to use a variable, you must give it a name or an identifier. if a variable name is more than one word, it is usually written in camelcase - first word is all lower case and any subsequent words have their first letter capitalized)
how to assign values to variables?
once you’ve created a variable, you can tell it what info you would like it to store for you - you assign a value to the variable i.e. var quantity = 3; … you can now use the variable by its name. the equal sign is an assignment operator, it says you’re going to assign a value to the variable… until you’ve assigned a value to a variable, programmers say the value is undefined.
What are the javascript Data Types?
What are some shorthand techniques for creating variables?
What are rules for naming variables?
What are arrays?
A special type of variable. It doesn’t just store one value; it stores a list of values. Consider using an array whenever you’re working w/ a list or a set of values that are related to each other; also, when you don’t know how many items a list will contain b/c when you create the array, you don’t need to specify how many values it’ll hold. If you don’t know how many items a list contain, rather than creating a long list of variables, use an array. Values in an array don’t have to be the same data
What ways can you create an array?
array literal - the preferred method… by writing each value on a separate line
array constructor - uses the “new” keyword followed by Array() - the values are then specified in the parenthesis and each separated by a comma.
What is an Expression?
Evaluates into (results in) a single value. Broadly speaking there are two types of expressions. Expressions rely on 2 things called operators; they allow programmers to create a single value from one or more values
What are the types of expression?
List some of the arithmetic operators?
Addition + (Adds one value to another)
Subtraction - (Subtracts one value from another)
Division / (Divides 2 values)
Multiplication * (multiplies 2 values using an asterisk)
Increment ++ (adds one to the current number)
Decrement – (subtracts one from the current number)
Modulus % (divides 2 values and returns the remainder)
What is the String Operator?
There is just one string operator: the + symbol. It is used to join the strings on either side of it - for situations where you may need to join two or more strings together to create one new string (concatenation)