-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.html
More file actions
43 lines (32 loc) · 1.08 KB
/
variables.html
File metadata and controls
43 lines (32 loc) · 1.08 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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Variables</title>
</head>
<body>
<!-- html tag 'script' is where you place your JavaScript code-->
<script>
// let creates a varaible called var1 which store the value 3
let var1 = 3;
// writes a message to the console
console.log(var1);
let calculation = 2 + 2
console.log(calculation);
// You can use a variable wherever you can use a value
console.log(calculation + 2);
let result = calculation + 2;
console.log(result);
// semi-colon represents "end of instruction"
// similar to a "." at the end of a sentence
let var2 = 'hello';
console.log(var2); console.log("good bye");
// reassigning a value to a variable
var1 = 5;
console.log(var1);
// increase the value of a variable
var1 = var1 + 1;
console.log(var1)
</script>
</body>
</html>