-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05-variables.html
More file actions
48 lines (34 loc) · 1.02 KB
/
05-variables.html
File metadata and controls
48 lines (34 loc) · 1.02 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Variables</title>
</head>
<body>
<script>
let variable1 = 3;
console.log(variable1);
let calculation = 2 + 2;
console.log(calculation);
console.log(calculation + 2);
let result = calculation + 2;
console.log(result);
let message = "Hello, World!";
console.log(message);
// Reassigning variable1
// This will overwrite the previous value of variable1
variable1 = 5;
console.log(variable1);
variable1 = variable1 + 1;
console.log(variable1);
// const cant be reassigned
const variable2 = 3;
// another way to declare a variable
var variable3 = 4;
// typeof shows the type of the variable
console.log(typeof variable1); // number
console.log(typeof message); // string
</script>
</body>
</html>