diff --git a/docs/tone_of_voice.mdx b/docs/tone_of_voice.mdx index 589dfb7f..7413a07a 100644 --- a/docs/tone_of_voice.mdx +++ b/docs/tone_of_voice.mdx @@ -53,7 +53,17 @@ Data over description - Show metrics, not marketing. Write complete, runnable examples with error handling, expected outputs, and realistic values (use environment variables, not placeholders). ```javascript -const apiKey = process.env.API_KEY; +function calculateTotal(numbers) { + if (!Array.isArray(numbers)) { + throw new Error('Input must be an array'); + } + if (!numbers.every((num) => typeof num === 'number' && !Number.isNaN(num) && isFinite(num))) { + throw new Error('Input must contain only finite numbers'); + } + return numbers.reduce((sum, num) => sum + num, 0); +} + +const apiKey = process.env.API_KEY; // Use only if needed for API calls try { const result = calculateTotal([10, 20, 30]);