-
Notifications
You must be signed in to change notification settings - Fork 77
/
09_objects.js
42 lines (31 loc) · 844 Bytes
/
09_objects.js
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
let student = {
name: "Bharat",
age: 21,
gender: "Male",
};
console.log(student); // { name: 'Bharat', age: 21, gender: 'Male' }
console.log(student.name); // Bharat
console.log(student.age); // 21
console.log(student.gender); // Male
function greet (user) {
console.log("Hi " + user.name + ", Your age is " + user.age);
}
let user = {
name: "Bharat",
age: 21
}
greet(user); // Hi Bharat, you are 21 years old
function greetUser (user) {
console.log("Hi " + user.name + ", Your age is " + user.age + " and you are " + user1.gender);
if (user.age >= 18) {
console.log("You are eligible to vote");
} else {
console.log("You are not eligible to vote");
}
}
let user1 = {
name: "Deepak",
age: 25,
gender: "Male"
}
greetUser(user1); // Hi Deepak, Your age is 25 and you are Male