JSDoc Documentation

Jsdoc
πŸ‘¨β€πŸ’Ό Code without documentation is like a recipe without instructionsβ€”technically all the ingredients are there, but good luck figuring out how to use them!
JSDoc is a documentation format that lives in special comments above your functions. The best part? TypeScript and your IDE understand JSDoc, so your documentation shows up in tooltips and autocomplete.
/**
 * Calculates the area of a rectangle.
 * @param width - The width of the rectangle
 * @param height - The height of the rectangle
 * @returns The area in square units
 * @example
 * const area = calculateArea(5, 10)
 * console.log(area) // 50
 */
function calculateArea(width: number, height: number): number {
	return width * height
}
When you hover over calculateArea anywhere in your codebase, you'll see this documentation!
Since TypeScript already provides type information (parameter types, return types), JSDoc is primarily useful for descriptions and examples in TypeScript projects. The @param and @returns tags add human-readable explanations that go beyond what types alone can convey.

Common JSDoc Tags

TagPurpose
@paramDocuments a function parameter
@returnsDocuments what the function returns
@exampleShows how to use the function
@throwsDocuments errors the function throws
@seeLinks to related documentation
🐨 Open
index.ts
and add JSDoc comments to each function.
Some functions in this exercise use built-in Math methods: - Math.pow(base, exponent) - raises base to the power of exponent (e.g., Math.pow(2, 3) returns 8) - Math.max(a, b) - returns the larger of two numbers - Math.min(a, b) - returns the smaller of two numbers
πŸ’° Put a brief description immediately after the opening /**.

Please set the playground first

Loading "JSDoc Documentation"
Loading "JSDoc Documentation"