Choose a Function
The Function Factory
INPUT (Argument)
getStatus(72) argument becomes parameter
FUNCTION BODY
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
OUTPUT (Return Value)
"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