Skip to the content.
3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 JS for Loops and Sprites

Big Idea 3.1 Hacks

I learned about variable and string operations, such as PEMDAS operations for numbers and string concatenation.

#POPCORNHACK PY
in0 = input("What is your name? ")
in1 = input("Your favorite color: ")
in2 = input("Your favorite candy: ")
in3 = input("Your favorite hobby: ")

#list = [in0, in1, in2, in3]
#dict = {in0, in1, in2, in3}

print(list)
print(dict)

print("Hi, my name is " + in0 + ". My favorite color is " + in1 + ", my favorite candy is " + in2 + ", and my favorite hobby is " + in3 + ".")
// POPCORNHACK JS
const input1 = prompt("What is your name?:");
const input2 = prompt("What is your age?:");
const var3 = prompt("What is your favorite Brawl Stars brawler?:");


// const myList = [var1, var2, var3];
// console.log(myList);


// const myDict = {name: var1, age: var2, favoriteFood: var3};
// console.log(myDict);


console.log("Hi, my name is " + var1 + ", I'm " + var2 + " years old, and my favorite brawler is " + var3 + ".");
#HOMEWORK PY
# In this hack, you will be given a set of personal information, and your job is to format and display it properly, along with generating a unique ID associated to that person using string slicing and concatenation.
full_name = input("Name: ")
age = int(input("Age: "))
email = input("Email: ")
hobby = input("Hobby: ")
pet = input("Pet Name: ")

initials = full_name[0] + full_name[full_name.find(" ") + 1] 
unique_id = initials + str(age) + pet[0]

formatted_info = "Personal Info:\n" \
                 "- Full Name: " + full_name + "\n" \
                 "- Age: " + str(age) + "\n" \
                 "- Email: " + email + "\n" \
                 "- Hobby: " + hobby + "\n" \
                 "- Pet: " + pet + "\n" \
                 "- Unique ID: " + unique_id

print(formatted_info)

login = input("Please input your ID: ")
if login == unique_id:
    print(":D")
else:
    print("please try again")
// HOMEWORK JS
// Recreate as JavaScript, with different parameters, a different/unique method of creating an ID, and a different way to display/store the data
let name = prompt('Full Name: ');
let age = prompt('Age: ');
let email = prompt('Email: ');
let hobby = prompt('Hobby: ');
let pet = prompt('Pet Name: ');

let initials = name[0] + name.substring(name.indexOf(" ") + 1, name.indexOf(" ") + 2);
let unique_id = initials + age.toString() + pet[0];

let info = "Personal Info:\n" +
                     "- Full Name: " + name + "\n" +
                     "- Age: " + age.toString() + "\n" +
                     "- Email: " + email + "\n" +
                     "- Hobby: " + hobby + "\n" +
                     "- Pet: " + pet + "\n" +
                     "- Unique ID: " + unique_id;


console.log(info);

let login = prompt("Please input your ID: ")
if (login === unique_id) {
    console.log(":D");
}
    else {
        console.log("D:")
    }