JS2 ClassNotes
JS2 ClassNotes
lege
Col
pna
A
Operators in JS
Used to perform some operation on data
e
Arithmetic Operators
+, -, *, /
lleg
a Co
Modulus
Exponentiation Apn
Increment
Decrement
Operators in JS
Assignment Operators
= += -= *= %= **=
lege
Col
pna
A
Operators in JS
Comparison Operators
Equal to ==
ge
Equal to & type
le
===
Not equal to !=
Col
Not equal to & type !==
pna
>, >=, <, <= A
Operators in JS
Logical Operators
lege
Col
a
||
n
Logical OR
Logical NOT ! Ap
Conditional Statements
To implement some condition in the code
if Statement
lege
Col
pna
A
Conditional Statements
if-else Statement
lege
Col
pna
A
Conditional Statements
else-if Statement
lege
Col
pna
A
Operators in JS
Ternary Operators
ge
condition ? true output : false output
olle
na C
Ap
MDN Docs
lege
Col
pna
A
Let‘s Practice
Qs1. Get user to input a number using prompt(“Enter a number:”). Check if the number is
a multiple of 5 or not.
lege
Col
pna
A
Let‘s Practice
Qs2. Write a code which can give grades to students according to their scores:
80-100, A
e
70-89, B
eg
60-69, C
50-59, D
Coll
a
0-49, F
Apn