-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforest.js
More file actions
60 lines (52 loc) · 1.19 KB
/
Copy pathforest.js
File metadata and controls
60 lines (52 loc) · 1.19 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
58
//this is for practicing the creation of objects
let raccoon = {
ability: 'foraging',
age: 0,
birthday (){
age++
},
forage (){
console.log('You found some berries')
}
}
raccoon.forage()
let person ={
//instance variables
skeleton: {
bones: 206,
marrow: 'fine'
},
organs:{
heart: 'beating',
lungs: 'breathing',
stomach: 'queasy',
brain: 'contemplative'
},
limbs:{
arms:{
amount:2
},legs:{
amount:2
}
},
//object methods
checkStatus (){
if(person.limbs.arms.amount===2&&person.limbs.legs.amount===2&&person.organs.heart==='beating'&&person.organs.lungs==='breathing'){
console.log('Everything is A OK')
}else{
console.log('Something is horribly wrong')
}
},
hurt (){
if(person.limbs.arms.amount>0){
person.limbs.arms.amount--
console.log('They lost an arm!!')
}else{
console.log('They already are out of arms!')
}
}
}
person.skeleton.bones //returns 206
person.checkStatus()
person.hurt()
person.checkStatus()