forked from HackYourFuture/JavaScript1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataType.js
More file actions
61 lines (32 loc) · 958 Bytes
/
dataType.js
File metadata and controls
61 lines (32 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Types of Data
let success = 'Congats! the data type of your variables is identical!';
console.log(success + ' * this is a string');
console.log(typeof success);
let failure = 'Oops! the data type of your variables is different!';
console.log(failure + ' * this is a string');
console.log(typeof failure);
let number = 1;
console.log(number + ' * this is a number');
console.log(typeof number);
let boolean = true;
console.log(boolean + ' * this is a boolean');
console.log(typeof boolean);
let array = [0, 1, 2, 3, 4];
console.log(array + ' * this is an object');
console.log(typeof array);
// Testing type of data
if (typeof success === typeof failure) {
console.log(success);
} else {
console.log(failure);
}
if (typeof success === typeof number) {
console.log(success);
} else {
console.log(failure);
}
if (typeof boolean === typeof array) {
console.log(success);
} else {
console.log(failure);
}