2. WARM UP
Take a look at this JSFiddle and fix the bugs(errors):
http://jsfiddle.net/appAcademyDan/8LUhJ/
3. REVIEW
From the previous JSFiddle:
What is an example of a variable?
What is an example of a value?
What is an example of an assignment operator?
*Write down answer and the line number you would find each.
4. DEFINITIONS - OPERATOR
What are they?
Operators are symbols that are used to add(+), subtract(-), multiple(*), divide(/) and do
modulo(%) on numbers.
The modulo operator returns the remainder after dividing two numbers.
Example of Operators
var sodaCost = 1.00;
var chipsCost = 2.00;
var totalCost = sodaCost + chipsCost;
// 4 divides evenly into 10 two times, this leaves a remainder of 2 left over.
var remainder = 10 % 4;
5. DEFINITION - COMMENTS
What Is It?
Comments are text that explains lines of code. Comments are ignored by the program
and are only meant for the programmer to read.
How do you use them?
There are two ways to add comments: two forward slashes “//” lets you add one
comment line. Using forward slashes with asterisks “/* */” lets you add one or more lines
of comments between the asterisks.
Example of Comments
/* We can add numbers together using Operators.
Take a look at the following example! */
var numCookies = 5 + 1;
// We can also divide two numbers using the division(/) operator!
var cookiesPerSecond = 10 / 5;
6. EXAMPLES OF OPERATORS IN ACTION
Addition
Multiplication
var add=5+15;
alert(add);
var mul=5*15;
alert(add);
Subtraction
Division
var sub=5-15;
alert(sub);
var div=5/15;
alert(div);
8. EXAMPLES OF VARIABLE MATH AND MOD
Var Math
Modulo
var num1=5;
var num2=10;
var add=num1+num2;
alert(add);
var mod=15%5;
alert(mod);
Var Math
Modulo
var mul=num1*num2;
alert(mul);
var mod=23%5;
alert(mod);
11. TICKET OUT THE DOOR
Identify the operators, value, and types of
data in each of the equations below.
var num1 = 5 + 15;
Operators: _________________
Value: _____________________
Type: ______________________
var mod = num1%3;
Operators: _________________
Value: _____________________
Type: ______________________