MODULE 3 · Control flow and functions
Reading · 15 min
Functions
Functions
Functions let you give a repeated operation a clear name, inputs, and result. This makes code easier to test and reuse.
Learning objectives
- Define a function with parameters
- Return a useful result
Package a repeated action into a named, testable unit. Focus on explaining each decision in your own words before relying on a pattern or shortcut.
Example
function formatGreeting(name) {
return `Hello, ${name}!`;
}
console.log(formatGreeting("Asha"));Summary
KEY TAKEAWAYS
- Functions describe a reusable action.
- Parameters make a function flexible and explicit.
Reading material
Functions practice prompt
Use the exercise in this lesson to check your understanding.
Your progress is saved on this device. Sign in to keep it across devices.
