Create a TypeScript function that analyzes a user's mood journal entries over time and returns a structured trend report.
analyzeMoodTrends(entries: MoodEntry[]): TrendReport
// MoodEntry: { date: string (ISO), mood: 1 | 2 | 3 | 4 | 5, note?: string }
// TrendReport: {
// average: number,
// trend: 'improving' | 'declining' | 'stable',
// streaks: { best: number, current: number }, // consecutive days with mood >= 4
// volatility: number, // standard deviation of mood scores
// weeklyAverages: { week: string, avg: number }[] // ISO week string
// }
Trend logic:
trend: 'stable' and empty arrays if fewer than 3 entriesWrite unit tests for 5 scenarios: improving trajectory, declining trajectory, stable, single entry, empty input.
No contributions yet.