-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice7.js
More file actions
35 lines (29 loc) · 816 Bytes
/
practice7.js
File metadata and controls
35 lines (29 loc) · 816 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
//OBJECTS IN JAVASCRIPT
var storeManager = {} //Approach 1
storeManager.rangeTilesperturn = 4;
storeManager.socialSkills = 50;
storeManager.streetSmarts = 50;
storeManager.health = 30;
var assistantManager = { //Approach 2
rangeTilesperturn: 2,
socialSkills: 30,
streetSmarts: 30,
health: 40,
}
assistantManager.nextAchievement = "get promoted "
console.log(assistantManager.health);
console.log(storeManager);
var house2 = {}
house2["rooms"] = 4; //Approach 3
house2["color"] = "pink";
house2["priceUSD"] = 12345;
console.log(house2);
var arrofKeys=["speed","altitude","color"];
var drone={
speed:100,
altitude:200,
color:"red",
}
for(var i=0;i<arrofKeys.length;i++){
console.log(drone[arrofKeys[i]]); // bracket notation can evaluate expressions
}