-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputer_object.js
54 lines (51 loc) · 1.2 KB
/
computer_object.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
43
44
45
46
47
48
49
50
51
52
53
54
let computer = {
_turnOn: false,
brand: 'IBM',
monitor: true,
model: 'SuperX 2340M',
components: {
_motherboard: 'IBM',
_cpu: 'Intel',
memory: 8,
hdd: 500
},
periferals: {
mouse: true,
keyboard: true,
},
greet(){
if(this._turnOn == false){
console.log('Turn on the computer first!');
}
else {
console.log('Hello World!');
}
},
get turnOn() {
return this._turnOn;
},
set turnOn(startButton){
if(typeof startButton === 'boolean'){
if(this._turnOn === startButton){
this._turnOn = startButton;
}
}
else{
console.log('Did you pressed the button?');
}
}
};
const pressButton = () =>{
if(computer._turnOn == false){
computer._turnOn = true
return 'Computer is turning on...';
}
else {
return 'Computer is turning off...';
}
};
//console.log(pressButton());
console.log(Object.entries(computer));
computer.greet();
const {components} = computer;//I used the Destructured Assignment to search the components into the computer / Usé la asignación destructurada para buscar los componentes dentro del computador
console.log(components)