-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtired.js
52 lines (51 loc) · 1.26 KB
/
tired.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
function ego(action) {
try {
action();
} catch (error) {
mind.error('Error, the brain needs rest:', error);
}
}
function life() {
let day = Math.random();
if (day < 0.5) {
mind.log('A smooth day, everything is going well!');
} else {
throw new Error('A tough day, problems arise...');
}
}
const mind = {
log: (message) => {
console.log(`Mind: ${message}`);
},
error: (message, error) => {
console.error(`Mind: ${message}`, error);
},
meditate: () => {
console.log('Mind: Meditating to regain clarity and calm...');
}
};
const heart = {
beat: () => {
console.log('Heart: Beating normally...');
},
stress: () => {
console.log('Heart: Beating rapidly due to stress...');
}
};
function needRest() {
heart.stress();
mind.log('The brain is resting, recharging its batteries...');
setTimeout(() => {
heart.beat();
mind.meditate();
mind.log('The brain is rested and ready to solve problems.');
}, 2000);
}
let egoTakingOver = true;
let mentalOverload = true;
if (egoTakingOver || mentalOverload) {
needRest();
} else {
mind.log('The brain is already in great shape!');
}
//github.com/berru-g/phylorythme