Documenting a function with a comment
A doc comment placed above a function. It says what the function does, lists its inputs with @param and its output with @returns, so others can use it without reading the code.
Understanding Documenting a function with a comment in ACARA Digital Technologies Years 9–10
What it does: @returns tells the reader what kind of value comes back from the function and what it means. This comment says why the code exists and what it is for. A comment like '// mark >= 50' would only repeat the code. A /** ... */ doc comment sits above a function and describes it. <!-- --> is an HTML comment and does not work in JavaScript. Use @param followed by the type, the parameter name and a short description. @returns is only for the output. // comments out one line. /** starts a multi-line doc comment that must end with */.
Common mistakes: A doc comment must start with /** (two stars). A single star makes an ordinary comment that documentation tools ignore. It should be /** Adds two numbers. */. The tag is misspelled. The tag that describes the output is @returns, so the line should be ' * @returns {number} n doubled.'.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 681–707) and word search (Modules 629–707).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
/** ... */Fill in the Blanks
Spot the Error
Student with a class code? Join your class →