Skip to the content.

Conditionals Popcorn Hacks

My finished conditionals popcorn hacks!

Popcorn Hacks!

You’re at the mall with your friends, and head into the Build-A-Bear store. Use conditionals to decide what kind of bear you want with different accessories! The employee comes up to you and explains the steps. She states…

“Choose Me: Pick that special furry friend — from a silly superhero to a sporty mascot and a cheerleading bunny to a snuggly teddy bear. Hear Me: Add a special sound effect to your furry friend. Stuff Me: Customize your creation with sounds, scents, stuffing and, of course, our iconic special heart that holds your love and wishes. Hug Me: Give your furry friend its first hug to make sure it’s stuffed just right. Dress Me: Turn up the fun with outfits and extras! Name Me: It’s official once your creation has a birth certificate of its bear-y own!”

Hack 1: Simple If-Statement

Create a variable based on what kind of stuffed animal you want.

%%js
let bearType = "Elephant"; //Choose what kind of bear you want: Teddy or Unicorn (Example: let bearType = "Teddyy")I want to do elephant, though...

if (bearType === "Elephant") { //Put the same bear type from above into this line
    console.log("You picked a snuggly Elephant bear! (Wow, that exists? Interesting...)");
}
<IPython.core.display.Javascript object>

Hack 2: If-Else Statement

Add a sound to the bear based on the type chosen.

%%js
let bearType = "Elephant"; //Put the same bear type as before.

if (bearType ==="Teddy") {
    console.log("Your Teddy snores...");//if the bearType is Teddy, then it snores
} else {
    console.log("Your Elephant makes a trumpeting elephant-y sound.");//if it is an elephant, then it makes an elephant sound.
}

<IPython.core.display.Javascript object>

Hack 3: Else-If Statement

Choose the stuffing type using an If-Else-If statement

%%js
let stuffingType = "Squishy"; //Choose a stuffing: Fluffy, Firm, or Squishy

if (stuffingType === "Fluffy") {
    console.log("Your bear will be extra soft and fluffy!");//if the stuffingType is Fluffy, then this will be printed out in the console
} else if (stuffingType === "Firm") {
    console.log ("Your bear will have a firm, sturdy feel.");//if it is firm, then this will be printed out in the console
} else {//if the stuffing is not fluffy or firm, then it is assumed that it is squishy.
    console.log("Your bear will be nice and squishy! Like a Squishmallow! Yaaay!!!");//This is printed out in the console.
}
<IPython.core.display.Javascript object>

Hack 4: Switch Statement

Use a switch statement to pick a bear outfit

%%js
let bearOutfit = "Eevee"; // Choose an outfit: "Superhero", "Cheerleader", "Pirate", "Princess" ORRR "Eevee"

switch (bearOutfit) {
    case "Superhero":
        console.log("Your bear is ready to save the day in a Superhero costume!");//if the bearOutfit is Superhero, then this is printed
        break;
    case "Cheerleader":
        console.log("Your bear will cheer with its Cheerleader outfit!");//if the bearOutfit is Cheerleader, then this is printed
        break;
    case "Pirate":
        console.log("Ahoy! Your bear is ready to sail in a Pirate costume!");//if the bearOutfit is Pirate, then this is printed
        break;
    case "Eevee":
        console.log("Your bear/elephant is ready to jump into a Pokemon battle!");
        break;
    default://if the outfit is not a superhero, cheerleader, pirate, or eevee, then it is assumed that it is a princess
        console.log("Your bear is ready for a royal adventure in a Princess outfit!");//this is printed out in the console
}

<IPython.core.display.Javascript object>

Hack 5: Complete Build-A-Bear Experience

Combine all conditionals to create new types of bears, stuffings, and outfits in a single code cell!

%%js
let bearType = "Ditto"; //Make a type of bear! (I really hope you guys know what Pokemon is...)
let stuffingType = "Squishy"; //Choose a type of stuffing! Veerrryyy squishy...
let bearOutfit = "Teddiursa"; //Create your own outfit!

// Step 1: Choose Me
if (bearType === "Elephant") { //Choose a bear type
    console.log("Yaaaayyy, an Elephant! That's my favorite animal! Oh, wait, I can't be biased, oh, uh, never mind..."); //Create a console message for the specified bear type
} else if (bearType === "Giraffe") {
    console.log("Wow! Your bear has a really, really, long neck...");
} else {
    console.log("Oh, wow, it's a Ditto! Wait, now what is it? Oh, wow, it keeps transforming!");//Ditto transforms in Pokemon 
}

//Repeat these steps. When finished, you should be able to choose your own type of bear, stuffing, and outfit within a single code cell. Be creative and have fun!!!
// Step 2: Hear Me
if (bearType === "Elephant") {
    console.log("A loud trumpeting sound plays. Wow, that's kinda loud...");
} else if (bearType === "Giraffe"){
    console.log("Wow, what a nice, melodious... uh... snorting sound?");
} else {
    console.log("Hmm... Your bear/ditto is just saying \"Ditto, ditto, ditto!\" Interesting...");
}

// Step 3: Stuff Me
if (stuffingType === "Squishy") {
    console.log("Your bear is very squishy! Very, very squishy...");
} else if (stuffingType === "Slimey") {
    console.log("Huh, your bear is kinda slimey... Uh, interesting choice, but you do you!");
} else {
    console.log("Wow, your bear is rock-hard! I'm not sure how that happened, but, uhm, enjoy!");
}

// Step 4: Dress Me
switch (bearOutfit) {
    case "Ranch Dressing":
        console.log("Huh, you chose an interesting outfit... very, uh, unique?");
        break;
    case "Programmer":
        console.log("Oh, it seems that this kind of bear can only lurk in the shadows and spends all their time on their computer. Huh...");
        break;
    case "Mortensen":
        console.log("Your bear sometimes seems to get a bit angry... they also seem to want to say \"Code, code, code\" a lot...");
        break;
    default:
        console.log("Aww, what a cute Teddiursa! It's ready for a Pokemon Battle!");
}

<IPython.core.display.Javascript object>