-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01-JS-variables.js
More file actions
57 lines (41 loc) · 1.18 KB
/
01-JS-variables.js
File metadata and controls
57 lines (41 loc) · 1.18 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
49
50
51
52
53
54
55
56
57
/*
=====================
JavaScript Variables
=====================
*/
// Declaring (Creating) JavaScript Variables
// Value = undefined
var x;
console.log(x);
x = 5;
console.log("x = " + x);
// JavaScript Data Types
var pi = 3.14;
console.log("pi = " + pi + " which is " + typeof pi);
var number = 1;
console.log("number = " + number + " which is " + typeof number);
var username = "iSuperMostafa";
console.log("username = " + username + " which is " + typeof username);
// One Statement, Many Variables
var pi = 3.14, number = 1, username = "iSuperMostafa";
// Re-Declaring JavaScript Variables
var carName = "Volvo";
console.log("carName = " + carName);
var carName;
console.log("carName = " + carName);
// JavaScript Arithmetic
var x = 5 + 2 + 3;
console.log("x = " + x);
var x = "Mostafa" + " " + "El-Marzouki";
console.log("x = " + x);
var x = "5" + 2 + 3;
console.log("x = " + x);
var x = 2 + 3 + "5";
console.log("x = " + x);
// Much Like Algebra
var itemPrice1 = 5;
console.log("itemPrice1 = " + itemPrice1);
var itemPrice2 = 6;
console.log("itemPrice2 = " + itemPrice2);
var total = itemPrice1 + itemPrice2;
console.log(itemPrice1 + ' + ' + itemPrice2 + ' = ' + total);