Save
ICT 8 JAVASCRIPT
VARIABLES AND COMPARISON STATEMENT
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Mama Mo
Visit profile
Cards (18)
Variable -
temporary storage
for values and expressions
Expressions
-formulas
that uses
mathematical
symbols
Declaring
a Variable:
var
case-sensitive
begin with a
letter
or an
underscore
ex: 1st-
not
accepted
first-
accepted
var_1st -
accepted
Avoid
using reserved words
>
reserved
by JS
Data
Types:
Integer
-
whole
number
Float
-
decimal
point
String
-
words
Boolean
-
true
or
false
Arithmetic Operation
> tell the expression what
operation
to be
done
We
can use
addition
to
combine
words. This is called "
concatenation
"
Modulus
> like division but answer is a
reminder.
if theres
no
reminder, the answer is
zero.
ex: 15%4=
3
4%2=
0
Increment
++
plus 1
decrement
--
minus 1
x=5 y=7 z=0
x=y++ -------> x=
7
y=
8
x=++y ------> x=
8
, y=
8
z=x++ * ++y -----------> x=
6
, y=
8
, z=
40
Comparison Statement
> evaluate the
equality
or
difference
between values or variables
= -
assigning
x=3
== -
equal
to 3==3
=== -
value
and
data
type 5===5(same value, same data type)
3!=2 - (3 is not equal to 2)
True
3!=3 - (3 is equal not to 3)
False
3>2 - (3 is greater than two)
True
Logical Operators
>
logic
between
expressions
,
variables
etc.
&
& and -
true
if
both
conditions are
true
-
False
if
one
condition is
false
II or -
true
even if
only
one
condition is true
-
false
if
both
conditions are
false
! not -
flips
answer ex: !(3>2) ----> !(T) {not true}
String literals are text
enclosed
in pairs of
quotation marks.
Numeric
digits that are
inside
the
quotation
marks will be considered as a
string
and will
lose
then its numeric value.
If the characters are
not
enclosed in
quotation marks
, JavaScript might interpret
the characters as an
object
or a
function.