Skip to the content.

3.1 Hacks

hacks

3.1 Popcorn Hack

var1 = input("Where do you want to visit?:")
var2 = input("Where do you live?:")
var3 = input("What is your favorite soccer club?:")

my_list = [var1, var2, var3]

my_dict = {
    var1,
    var2,
    var3
}

print(my_list)
print(my_dict)

print("I want to visit " + var1 + ", I live in " +  var2 + ", and my favorite soccer club is " + var3)
['London', 'San Diego', 'Chelsea']
{'Chelsea', 'London', 'San Diego'}
I want to visit London, I live in San Diego, and my favorite soccer club is Chelsea

3.1 hw hack

// Defining parameters
const fullName = "Gyutae Kim";
const age = 16;
const email = "gyutae513@gmail.com";
const hobby = "Soccer";
const dietaryPreferences = "N/A";

// Creating a unique ID by using a hash of the name and age
const uniqueID = `${fullName.split(" ")[0].slice(0, 3)}-${age}${fullName.split(" ")[1].slice(0, 3)}`;

// Storing data in an object
const personalInfo = {
    fullName: fullName,
    age: age,
    email: email,
    hobby: hobby,
    dietaryPreferences: dietaryPreferences,
    uniqueID: uniqueID
};

// Function to display the personal information
function displayInfo(info) {
    return `
        Personal Info:
        - Full Name: ${info.fullName}
        - Age: ${info.age}
        - Email: ${info.email}
        - Hobby: ${info.hobby}
        - Dietary Preferences: ${info.dietaryPreferences}
        - Unique ID: ${info.uniqueID}
    `;
}

// Logging the formatted info to the console
console.log(displayInfo(personalInfo));