8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave
Primitive Types & Conditionals | Cheat Sheet
1. JavaScript Values
Basically In JavaScript values are of two
categories.
Primitive Types
Reference Types
1.1 Primitive Types
Number
Boolean
String
Undefined, etc.
Primitive Type Description
All the numbers are of Number
Number
type.
Boolean values are either true
Boolean
or false.
String is a stream of characters.
The String should be enclosed
String
with Single quotes, Double
quotes, or Backticks.
If a value is not assigned to the
variable, then it
takes undefined as its
Undefined value. In
JS, undefined refers to
the value that is not being
assigned.
1.2 Operators
1.2.1 typeof()
The
typeof() operator is used to find the type
of value.
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 1/4
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave
JAVASCRIPT
1 let a = 900;
2 let b = 9.2;
3 console.log(typeof(a)); /
4 console.log(typeof(b)); /
Try out changing the different Values in the
below Code Playground and check the
output in the console.
HTML CSS JAVASCRIPT
1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 Your HTML code goes here. W
6 </body>
7 </html>
2. Converting String to a
Number
In JavaScript, when we combine the number
and string, it results in a string.
The
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 2/4
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave
parseInt() function accepts a string and
converts it into an integer.
JAVASCRIPT
1 let a = '20';
2 console.log(typeof(a)); /
3
4 let b = parseInt(a);
5 console.log(typeof(b)); /
3. Conditional Statements
The Conditional Statement allows you to
execute a block of code only when a specific
condition is true.
If...Else Statement:
Syntax:
JAVASCRIPT
1 if (conditionA) {
2 Block1;
3 }
4 else if (conditionB) {
5 Block2;
6 }
7 else {
8 Block3;
9 }
Try out changing the colors, increment, and
decrement Values in the below Code
Playground and check the output.
HTML CSS JAVASCRIPT
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href
5 <script src="https://code.j
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 3/4
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave
5 <script src https://code.j
6 <script src="https://cdn.j
7 <script src="https://stack
8 </head>
9 <body>
10 <div class="bg-container te
11 <h1 class="counter-headi
12 <p id="counterValue" cla
13 <div>
14 <button onClick="onDec
15 <button onClick="onRese
16 <button onClick="onInc
17 </div>
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 4/4