CCv1.0 ppt02 - operators
Upcoming SlideShare
Loading in...5
×
 

CCv1.0 ppt02 - operators

on

  • 85 views

 

Statistics

Views

Total Views
85
Views on SlideShare
85
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

CCv1.0 ppt02 - operators CCv1.0 ppt02 - operators Presentation Transcript

  • OPERATORS [PROJECT: COOKIE CLICKER]
  • WARM UP Take a look at this JSFiddle and fix the bugs(errors): http://jsfiddle.net/appAcademyDan/8LUhJ/
  • 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.
  • 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;
  • 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;
  • 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);
  • TRY THIS JSFIDDLE! http://jsfiddle.net/appAcademyDan/5aENL/
  • 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);
  • TRY THIS JSFIDDLE! http://jsfiddle.net/appAcademyDan/S7dnF/
  • HOMEWORK http://jsfiddle.net/appAcademyDan/ePhW8/
  • 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: ______________________