HAP ready to create like a chef

Function Factory

Station 4 Demo

Watch the function factory in action! Adjust the inputs and see how parameters receive values, the function body executes, and return values come out. Try different Robot ID Card values!

Choose a Function

The Function Factory

getStatus(72)
⬇️ argument becomes parameter
function getStatus(value) {
    // value = 72
    if (value > 75) return "High";
    if (value > 25) return "Medium";
    return "Low";
}
🔍 72 > 75? No. 72 > 25? Yes! → return "Medium"
➡️ return sends back the result
"Medium"
let result = getStatus(72); // result = "Medium"

Quick Test: Robot ID Card Values

Click to test with HAP's actual values:

Scope: Variables Inside Stay Inside

Outside the function
let result = getStatus(72); // "Medium" console.log(value); // ❌ Error! value is not defined
Inside getStatus()
let value = 72; // ✅ Exists here return "Medium"; // ✅ Sent back