Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSS Colors, JavaScript Variables, Conditionals and Basic Methods

Similar presentations


Presentation on theme: "CSS Colors, JavaScript Variables, Conditionals and Basic Methods"— Presentation transcript:

1 CSS Colors, JavaScript Variables, Conditionals and Basic Methods
© 2017, Akhilesh Bajaj. All rights reserved.

2 © 2017Akhilesh Bajaj, All rights reserved.
Color Coding in CSS3 - Binary versus Decimal versus Hexadecimal Quantity: 2, 8, 9, 10, 11, 16, 17. -Binary Digit = bit, can represent 2 values One hexadecimal digit is represented using 4 bits, can represent 16 values RGB Scheme for colors: 2 hexadecimal digits or 8 bits each. How many total colors can we have? -Look up HTML5 color wheels. © 2017Akhilesh Bajaj, All rights reserved.

3 © 2017Akhilesh Bajaj, All rights reserved.
ASCII versus Unicode ASCII code : 8 bits. How many characters can we represent? ASCII is old. Unicode is the current standard. Unicode: 16 bits. How many characters can we represent JavaScript Methods for printing the Unicode values of characters fromCharCode(i) charAt(i) © 2017Akhilesh Bajaj, All rights reserved.

4 ASCII versus Unicode -ASCII versus Unicode
-Understand the difference between \u0041 and 65 as code representations for the letter ‘A’. In Class Assignment: Write a program that prints out the following table: Character Code A Z a z

5 A script element that embeds JavaScript in the head section
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

6 JavaScript in the body of an HTML document
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

7 A nonscript element in the body of an HTML document
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

8 How to split a statement over two or more lines
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

9 A JavaScript function with the identifiers highlighted
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

10 Camel casing versus underscore notation
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

11 const Keyword in JavaScript
const defines a constant that can be used throughout the code symbolically. If the value needs to be changed, it is only changed once. It also makes the code easier to read. E.g., const PI = 3.142; var circ, rad; rad = parseInt(prompt(“Enter radius”)); circ= 2*PI*rad; © 2018, Akhilesh Bajaj

12 A block of JavaScript code with the comments highlighted
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

13 © 2015, Mike Murach & Associates, Inc.
How to code comments Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

14 Common methods of the window object
Do a for loop using confirm() method on w3 schools code. Murach's JavaScript (2nd Ed.), C2

15 A statement that calls the prompt method with the object named omitted
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

16 Two methods of the window object for working with numbers
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

17 Examples that use the parseInt and parseFloat methods
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

18 The same examples with the parse methods embedded in the alert method
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

19 Other examples of parse methods
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

20 © 2015, Akhilesh Bajaj. All rights reserved.
Fun In Class Assignment for if and for Write a javascript based program, called ComputeTotalSalary for our sales force. The program should have 1 html file, 1 css file and 1 js file. It should ask the user to input the name of the salesperson (String), the base salary and the total sales of last year (check they Are both numbers). If the sales are below zero, the program should print an error and exit. If the sales are between $1 and $25,000, the program should add a bonus of 5% of the sales to the base. If the sales are between $25,000 and $50,000, the program should add a bonus of 10% of sales. If the sales are between $50,000 and $100,000 it should add a bonus of 15% of sales. Sales over $100,000 merit a 20% of-sales bonus. Finally, the program should print the statement: The final salary of is $XXXX.XX and ask the user if they want to run again. If the user says Yes or Y, it should run again, otherwise, it should say thanks and exit. © 2015, Akhilesh Bajaj. All rights reserved.

21 One property of the window object
Fun Assignment: Write an HTML page with one button, labeled Search. When clicked, it opens a new window with your favorite search engine. Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

22 Two methods of the document object
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

23 write() and writeIn() statements in the body
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

24 Examples of number values
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

25 Common arithmetic operators
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

26 The order of precedence for arithmetic expressions
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

27 The most useful assignment operators
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

28 The concatenation operator for strings
Escape sequences that can be used in strings Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

29 How to declare string variables and assign values to them
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

30 How to code compound assignment statements
Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.

31 How escape sequences can be used in a string
How to declare Boolean variables and assign values to them Murach's JavaScript (2nd Ed.), C2 © 2015, Mike Murach & Associates, Inc.


Download ppt "CSS Colors, JavaScript Variables, Conditionals and Basic Methods"

Similar presentations


Ads by Google