-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
55 lines (44 loc) · 1.76 KB
/
main.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
55
// // introductory callback example
// const sum = (a, b) => a + b;
// const diff = (a, b) => a - b;
// const calculate = (callback, a, b) => {
// const result = callback(a, b);
// console.log(callback, `of ${a} and ${b} equals ${result}`)
// }
// calculate(sum, 40, 2);
// calculate(diff, 80, 38);
/* CONVENIENCE FUNCTIONS */
// generate a variable amount of lag for each waiting period
const lag = (min, max) =>
Math.floor(Math.random() * (max - min + 1)) + min;
// generate a variable amount of lag for each waiting period
const minPizzaLag = 1000;
const maxPizzaLag = 2000;
// generate a boolean representing whether a pizza has
// actually been been made
let pizzaProbability = 95;
const pizzaMakingEvent = () =>
Math.random() * 100 > 100 - pizzaProbability;
// convenience log functions
const orderPlaced = (id) => {
console.time(id)
console.log(`Order placed at ${new Date()}`)
}
const orderServed = (id) => {
console.log(`Served the table pizzas at ${new Date()}`)
console.timeEnd(id)
}
const oops = (error) => console.log('I\'m sorry to have to tell you, but there\'s been a problem in the kitchen folks, specifically', error)
// generate a variable amount of lag for each waiting period
const minCleanLag = 100;
const maxCleanLag = 2500;
// generate a boolean representing whether a kid has actually
// cleaned their room or not
let roomCleaningProbability = 75;
const roomCleaningEvent = () =>
Math.random() * 100 > 100 - roomCleaningProbability;
// convenience console.log functions
const log = (msg) => console.log(msg)
const rewardIndividual = (result) => console.log(result + ', Great job!')
const punishIndividual = (err) => console.log(err + ', You\'re grounded for the week!')
const logInFamilyCalendar = () => console.log('result recorded in family journal');