**:Pencil:Homer Jay Simpson is a student at TC Columbia. This script represents Homer's daily routine with his friends Suga, Hanwen, Yuxing, and Barry.** ![](https://www.azcentral.com/gcdn/-mm-/fd5c5b5393c72a785789f0cd5bd20acedd2d2804/c=0-350-2659-1850/local/-/media/Phoenix/BillGoodykoontz/2014/04/24//1398388295000-Homer-Simpson.jpg?width=660&height=373&fit=crop&format=pjpg&auto=webp) ```javascript= var person = { name: "Homer Jay Simpson", age: 25, energy: 100, money: 500, OutlookPicUrl: "https://www.azcentral.com/gcdn/-mm-/fd5c5b5393c72a785789f0cd5bd20acedd2d2804/c=0-350-2659-1850/local/-/media/Phoenix/BillGoodykoontz/2014/04/24//1398388295000-Homer-Simpson.jpg?width=660&height=373&fit=crop&format=pjpg&auto=webp", isDrunk: false, sangSong: false, school: { name: "TC Columbia", yearsAttended: 2, onCampus: true } }; // The Main buildings at TC Columbia var schoolBuildings = ["Zankel Hall", "Horace Hall", "Grace Dodge Hall"]; // Homer's friends and their usual locations var friends = ["Suga", "Hanwen", "Yuxing", "Barry"]; var locations = { "Suga": schoolBuildings[0], // Zankel Hall "Hanwen": schoolBuildings[1], // Horace Hall "Yuxing": schoolBuildings[2], // Grace Dodge Hall "Barry": schoolBuildings[0] // Zankel Hall }; // Homer's morning routine includes a workout session function goGym() { // Decrease energy after a workout person.energy -= 30; return person.energy; } // Homer buys breakfast after his workout. function buyBreakfast() { var cost; if (person.age > 20) { cost = 20; } else { cost = 15; } // Deduct money for breakfast person.money -= cost; return person.money; } // Homer takes the subway to school. function takeSubway(waitTime) { var fare = 5; // If the waiting time exceeds 15 minutes, it indicates that Homer may need to make a transfer, // which comes with an additional fare of 2 units. if (waitTime > 15) { fare = fare + 2; } // Deduct money for subway fare person.money -= fare; return person.money; } // Homer meets up with a friend. function meetFriend(friendName) { var location = locations[friendName]; return location; } // Homer studies after class. function studyAfterClass(location) { if (location === "Library") { // Decrease energy while studying at the library person.energy -= 20; } else { person.energy -= 10; } return person.energy; } // Evening activities: Homer and friends decide to drink together. function drinkWithFriends() { var drinks = ["beer", "Jack Daniel", "gin", "rum"]; var drinkLimit = 10; for (var i = 0; i < drinkLimit; i++) { person.energy -= 5; if (i == 9) { person.isDrunk = true; person.energy -= 10; // Change Homer's picture when he gets drunk person.OutlookPicUrl = "https://www.thewrap.com/wp-content/uploads/files/2013/Jun/14/97571/homerizlazyazzcouchpotato.gif"; // Additional energy deduction when drunk person.energy -= 10; break; } } return { energy: person.energy, isDrunk: person.isDrunk }; } // Homer gets a meal after his drinks. function eatAndDrink(drinksCount) { // Deduct money for meals and increase energy person.money -= drinksCount * 20; person.energy += drinksCount * 10; return { energy: person.energy, money: person.money }; } // If Homer gets drunk, he goes to sing at a KTV. function goToKTV() { if (person.isDrunk) { // Decrease energy when singing at KTV person.energy -= 20; person.sangSong = true; } } // After KTV, Homer goes for some late-night shopping. function shopping() { var itemsBought = ["T-shirt", "jeans", "hat"]; // Calculate the total cost of items bought var totalCost = itemsBought.length * 50; // Deduct money for shopping person.money -= totalCost; } // Finally, Homer returns home. function goHome(distance) { // Decrease energy for the journey home person.energy -= distance * 2; return person.energy; } // Homer has a dog and he needs to feed it before sleeping. function feedDog() { var dogFoodCost = 30; // Deduct money for dog food person.money -= dogFoodCost; return person.money; } // Checking Homer's status at the end of the day. function checkStatus() { if (person.energy < 0) return "Rest"; if (person.money < 0) return "No Money"; return "Everything is Normal"; } //Homer's daily routine. function dailyRoutine() { goGym(); buyBreakfast(); takeSubway(10); var friendLocation = meetFriend("Hanwen"); studyAfterClass(friendLocation); drinkWithFriends(); if (!person.isDrunk) { eatAndDrink(3); goHome(5); feedDog(); } else { goToKTV(); shopping(); goHome(5); feedDog(); } } //Executing Homer's daily routine. dailyRoutine(); sleep(); ``` ![](https://hackmd.io/_uploads/ryEang7zp.png)