Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
21 views

JavaScript Course 1

This document provides an introduction to basic JavaScript concepts through a series of coding examples grouped into levels. It covers numeric operators, strings, comparisons, and special characters. The examples show how to perform calculations and manipulate text using JavaScript syntax and functions. Key concepts demonstrated include data types, concatenation, ordering operations, and accessing string properties.

Uploaded by

asheeshmisra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

JavaScript Course 1

This document provides an introduction to basic JavaScript concepts through a series of coding examples grouped into levels. It covers numeric operators, strings, comparisons, and special characters. The examples show how to perform calculations and manipulate text using JavaScript syntax and functions. Key concepts demonstrated include data types, concatenation, ordering operations, and accessing string properties.

Uploaded by

asheeshmisra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

THE LAST GREAT UNCHARTED FRONTIER

The CLIFFS OF VALUE


Level 1
LEVEL ONE
THe Prompt & some Basic Numbers
24
>
24
3.14
>
3.14
The JavaScript Prompt, aka the Console >
What gets returned from the code
JavaScript automatically recognizes numbers
LEVEL ONE
Operators
10
Common Operators used in JavaScript Syntax:
> 6 + 4
12
> 3 * 4
4
> 9 - 5
3
> 12 / 4
addition subtraction
multiplication division
3
> 43 % 10
modulus
Modulus returns the
remainder after division.
LEVEL ONE
Order of Operations: PEMDAS
36
Grouping Expressions in JavaScript
> (5 + 7) * 3
12 * 3
9
> (3 * 4) + 3 - 12 / 2
12 + 3 - 12 / 2
12 + 3 - 6
-16
> (-5 * 6) - 7 * -2
-30 - 7 * -2
4
> 4 + (8 % (3 + 1))
4 + (8 % 4 )
4 + 0
-30 - -14
LEVEL ONE
Comparators
true
Common Number Comparators used in JavaScript Syntax:
> 6 > 4
false
> 3 == 4
false
> 9 < 5
true
> 12 != 4
greater than less than
equals not equals
boolean value
two equal signs!
the not symbol
true
greater or equal
> 8 >= -2
true
less or equal
> 10 <= 10
LEVEL ONE
Strings
How JavaScript stores and processes !at text
>
>
"Raindrops On Roses"
"Raindrops On Roses" + " And " + "Whiskers On Kittens"
>"Whiskers On Kittens"
"Raindrops On Roses" "Whiskers On Kittens"
"Raindrops On Roses And Whiskers On Kittens"
Plus will glue Strings together
Strings need quotes!
LEVEL ONE
These are a few of my favorite...Strings
Concatenation works with numbers and their expressions, too.
>"The meaning of life is " + 42
"The meaning of life is 42"
Notice the extra space!
>"The meaning of life is" + 42
"The meaning of life is42"
Uh oh...what happened?
Concatenation adds no
spaces, so we need to
add our own.
LEVEL ONE
These are a few of my favorite...Strings
Concatenation works with numbers and their expressions, too.
"Platform " + 9 + " and " + 3/4
"Platform 9 and 0.75"
Expressions get evaluated!
>
Make strings out of
expressions that you
want to see in their
original format.
"Platform " + 9 + " and 3/4" >
"Platform 9 and 3/4"
LEVEL ONE
Special characters inside Strings
Some characters need backslash notation in JavaScript Strings
>
>
advances to the next tab stop
"Flight #:\t921\t\tSeat:\t21C"
"Flight #: 921 Seat: 21C"
Adds a quotation mark but without
ending the string too early.
"Login Password:\t\t\"C3P0R2D2\""
"Login Password: "C3P0R2D2""
LEVEL ONE
Special characters inside Strings
Some characters need backslash notation in JavaScript Strings
>
>
shifts the printout to a new line
"Origin\\Destination:\tOrlando(MCO)\\London(LHR)"
"Departure:\t09:55A\nArrival:\t14:55P"
"Origin\Destination: Orlando(MCO)\London(LHR)"
Places a backslash itself in the String
"Departure: 09:55A
Arrival: 14:55P"
LEVEL ONE
String Comparisons
Checking for matching strings and alphabetical ordering
>
>
"The Wright Brothers" == "Super Mario Brothers"
"The Wright Brothers" != "the wright brothers"
false
true
Case counts!
> "The Wright Brothers" == "The Wright Brothers"
true
Double equals will compare EXACT contents
Case counts!
Not equals returns true if there is a mismatch
LEVEL ONE
String Comparisons
The length of strings can be accessed with the .length property
28
>
Case counts!
"antidisestablishmentarianism".length
39
> "One Fish, Two Fish, Red Fish, Blue Fish".length
Spaces and any non-alphabetic
characters are counted, too!
Returns a number value

You might also like