-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_basic.js
More file actions
54 lines (43 loc) · 898 Bytes
/
Copy path01_basic.js
File metadata and controls
54 lines (43 loc) · 898 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
var a = 10; // function scope variable
let b = 20; // block scope variable
const c = 30;
a = 100;
b = 200;
// c = 300; // this will give an error because const value cannot be changed
console.log(a + b + c);
//How to Use Conditions and Loops
if (a == 200) {
console.log("this is if condition");
} else {
console.log("this is else condition");
}
//Function Example
function fruit(item) {
console.log("fruit is " + item);
}
fruit("apple");
fruit("banana");
//For Loop
for (var a = 0; a <= 10; a++) {
console.log(a);
}
//While Loop
var a = 0;
while (a <= 10) {
console.log(a);
a++;
}
//How to Use Arrays and Objects
var user = ["anil", "sam", "peter", "bruce"];
for (var a = 0; a < user.length; a++) {
console.log(user[a]);
}
//Object Example
var user = {
name: "Umar",
city: "Kashmir",
age: 23,
};
console.log(user.name);
console.log(user.city);
console.log(user.age);