--- tags: assignment --- # Data of My Life_Wenyi_Oct.30 ```javascript= // Wenyi is an ordinary girl when she sleeps. let day = [ "day0", "day1", "day2" ]; let currentIndex = 0; let currentDay = day[currentIndex]; let me = { name: "Wenyi"; isSleep: true; currentIdentity: "ordinary girl" }; // Every morning Wenyi awakes // to find herself transformed into legendary beings. // day1 starts. Wenyi wakes up. let currentIndex = currentIndex++; me.isSleep = false; me.currentIdentity = "Medusa";//Medusa can //turn evil person into stones. function walk(){ //Medusa walks out to the street while scans the crowd //to test people are evil or good. function testThePerson(isEvil) { let answer=""; if (isEvil) { answer = "Turn the person into stones"; }else{ answer = "Give the person a rose";} return answer; } } // day1 is over. Wenyi sleeps // and is turned back into an ordinary girl. me.isSleep = true; me.currentIdentity = "ordinary girl"; // day2 starts. Wenyi wakes up. let currentIndex = currentIndex++; me.currentIdentity = "Harry Potter"; me.isSleep = false; }; // Harry Potter has to collect three Deathly Hallows // in order to kill Voldemort. // Below are the names of the three Deathly Hallows. const names ["Invisibility Cloak", "Ressurection Stone", "Elder Wand"]; // I am provided with three locations, A, B and C // where hidden the Hallows. // However, I don't know which location is hidden which hallow. // I have to call the location's name to see // if it is matched with any of the Hallows. // I arrive at one of the locations. function deathlyHallows (val) { let answer = ""; switch (val){ case "locationA": answer = "Invisibility Cloak"; break; // I call A, it does not answer. case "locationB": answer = "Ressurection Stone"; break; // I call B, it does not answer. case "locationC": answer = "Elder Wand"; break; // I call C, it answers. } return answer; } deathlyHallows(locationC); // Phew! I successfully find the "Elder Wand". // day2 is over. Wenyi sleeps. // and is turned back into an ordinary girl. let me = { name: "Wenyi"; currentIdentity: "ordinary girl"; isSleep: true }; ```