-
Notifications
You must be signed in to change notification settings - Fork 7
/
04-variableTypes.html
46 lines (39 loc) · 1.42 KB
/
04-variableTypes.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Demo</title>
</head>
<body>
<script type="text/javascript">
// Let's learn different types of variables.
// document.write writes HTML expressions or JavaScript code to a document
// integers
var integer = 20;
document.write(integer);
// floating point number
var floatingPoint = 20.4324243232;
document.write(floatingPoint);
// Negative number
var negativeNumber = -101;
document.write(negativeNumber);
// strings
// Quotes tell JS that it is a string versus another variable
// Use a backslash to escape characters within strings
var string = 'This is a \'string\' of text'
document.write(string)
// boolean variables == true or false
var trueFalse = true;
if (trueFalse == true) {
document.write("It's true, it really is!");
} else {
document.write('Nope, false YO!');
}
// Playing with variables and strings
var name = "Dale";
var age = 40;
document.write(name + ' is my name, and I am ' + age + ' years old');
</script>
</body>
</html>