โ† Home BP ยท 7-9 ๐Ÿ•

Pizza Recipe Machine

69
Day 1 ๐Ÿ”ฅ
๐ŸŽฏ Today's Missions
๐Ÿ… ๐Ÿง€ ๐ŸŒถ๏ธ โœจ
๐Ÿ•
Pizza Planet Universe
Pizza Recipe Machine
In the Pizza Planet kitchen, the head chef writes ONE recipe card โ€” then the ovens use it to bake a THOUSAND pizzas! That recipe card is a FUNCTION: a named block of code you write once and call by name anytime. Hand it an ingredient (a parameter), and out pops a pizza. Write the recipe once โ†’ bake forever!

๐Ÿ• What we're MAKING today: My Pizza Recipe

In Opposite Potion you flipped rules with NOT, and in Logic Boss you combined checks with AND and OR. Today you package those rules into a FUNCTION โ€” a reusable recipe! ๐Ÿณ

What is a function? It's a named recipe. You write the steps ONCE inside function makePizza(topping) { ... }, then call it by name: makePizza("cheese"). The word in the parentheses โ€” topping โ€” is a parameter: an input slot. Each call can pass a different ingredient (an argument), and the SAME recipe makes a DIFFERENT pizza! Real apps do this everywhere: one sendMessage(friend) function, a million messages. One recipe, infinite pizzas! ๐Ÿ•

๐Ÿ”— Last time you used ! to flip a rule. Today you write function makePizza(topping) โ€” a recipe you can call with makePizza("pepperoni") again and again. The AND/OR/NOT rules live INSIDE the function now, so every pizza you bake follows them automatically! ๐Ÿ•
โ— โ— โ— pizza-machine.js JavaScript

    
๐Ÿ’ก Tap a red chip in the code to change the topping or the rule function = recipe ยท call = bake!
kitchen preview LIVE
๐Ÿ”ฅ Live Recipe Result
โ€ฆ
๐Ÿ• Pizza Counter (oven) 0 baked
Step 1 / 4
First Order! Bake ONE cheese pizza by calling your recipe. Pick the cheese topping, then press ๐Ÿ”ฅ Bake! to call makePizza("cheese").
๐Ÿง€ Parameter โ€” which topping do you pass into makePizza( )?
๐Ÿ“– Function Body โ€” the special rule INSIDE your recipe (changes every pizza you bake!)
๐Ÿ“‹ Your 4 Pizza Challenges
0 of 4 challenges complete
๐Ÿ•
You Built the Pizza Recipe Machine!
You wrote ONE function and called it with many different toppings โ€” one recipe, infinite pizzas! That's how every real app works: write it once, use it forever. Your recipe is ready to save and share! ๐Ÿ•โœจ

๐Ÿ’ซ What You Learned

  • A function is a named recipe: function makePizza(topping){ ... } โ€” write the steps once.
  • A parameter is an input slot (the word topping). Each call passes a different ingredient (an argument) like "cheese" or "pepperoni".
  • Calling a function = makePizza("cheese"). The function runs its steps and returns a result.
  • One function, MANY calls: the same recipe made cheese, pepperoni, and veggie pizzas โ€” just by passing different toppings!
  • The rule lives inside the function, so changing it affects every pizza you bake โ€” that's reusable code.
๐Ÿ• Your Creation
My Pizza Recipe
๐Ÿ• Come Back Tomorrow!
Next up: RETURN VALUES โ€” your function can do math and give back a number (like the pizza's price)! Turn your recipe into a smart calculator the kitchen uses to total every order! ๐Ÿ’ฐ
๐Ÿ  Home
Nice! ๐ŸŽ‰