-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaily_diet_generator.js
64 lines (53 loc) · 2.64 KB
/
daily_diet_generator.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
56
57
58
59
60
61
62
63
64
// choose a random element from an array
const randomArrayElement = array =>
{
return array[Math.floor(Math.random()*array.length)];
}
//let trialArray = ["alma", "béta","gamma","kappa"];
//console.log(randomArrayElement(trialArray)); // check if we can select a random element
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// List all the foods
const foodsObject = {
breakfast: ["tojásrántotta", "zabkása"],
tenHourLunch: ["alma","keksz"],
lunch: ["rántotthús bulgurral","csilisbab"],
snack: ["sajtos zabkeksz", "kókuszos zabkeksz"],
dinner: ["tonhalsaláta", "virsli"]
}
//console.log(foodsObject.breakfast);
//------------------------------------------------------------------------------------------
// List all the greetings:
const greetingArray = ["Örülök, hogy látlak!", "De jó újra találkozni!", "Hát újabb nap érkezett el!"]
//------------------------------------------------------------------------------------------
// List all the motivations:
const motivationArray = ["Még egy erős nap!", "Kitartást a mai naphoz is!", "Fogod tudni tartani ma is a diétát látom!", "No pain, no Gain!", "Dig deeper!"]
//------------------------------------------------------------------------------------------
// List all the smileis:
const smileis = [":)", ":D", ":P", "XD", ";D", ";)"]
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// creat a random daily diet based on the input food list
const randomDietGenerator= foods => {
const dailyDietObj = {
breakfast: "",
tenHourLunch: "",
lunch: "",
snack: "",
dinner: ""
}
dailyDietObj.breakfast = randomArrayElement(foods.breakfast);
dailyDietObj.tenHourLunch = randomArrayElement(foods.tenHourLunch);
dailyDietObj.lunch = randomArrayElement(foods.lunch);
dailyDietObj.snack = randomArrayElement(foods.snack);
dailyDietObj.dinner = randomArrayElement(foods.dinner);
return dailyDietObj;
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// console.log(randomDietGenerator(foodsObject)); // test the diet generator
const dailyDiet= randomDietGenerator(foodsObject);
console.log("Szia! "+ randomArrayElement(greetingArray)+ " " + randomArrayElement(motivationArray) + " " + randomArrayElement(smileis));
console.log("A napi étrended a következő:");
console.log("Reggeli: " + dailyDiet.breakfast);
console.log("Tízórai: " + dailyDiet.tenHourLunch);
console.log("Ebéd: " + dailyDiet.lunch);
console.log("Uzsonna: " + dailyDiet.snack);
console.log("Vacsora: " + dailyDiet.dinner);