What is a function?
A function is a named action that takes inputs and gives back an output.
Difficulty 2/5
Mental model
Plain English
A function is a reusable action. You give it inputs, it does something, it returns an output. Functions are how apps stay organized — instead of repeating the same steps everywhere, you call a function.
Analogy
A function is a recipe card. The ingredients are inputs, the cooked dish is the output, the steps are the body.
Jessica's wedding portal
createTask({ title, dueDate, weddingId }) → returns the saved task with an id.
Agentify CRM
assignConversation({ conversationId, agentId }) → returns the updated conversation.
Go deeper
A named action with inputs and an output.
Common mistakes
- Putting too much into one function. If it does five things, split it.
- Calling a function but ignoring its return value.
AI-agent trap
Agents create giant 'do everything' functions. Ask for one function per intent.
Quick check
What does a function always have?
Summary
A function bundles a sequence of steps under one name. You can call it from many places without copying the steps.
Confidence: