← All Exercises
Attribute Monthly Cloud Cost by Owner
basicjavascript
Background
Cost optimization starts with attribution. Untagged or misattributed spend makes every optimization conversation anecdotal.
Problem
Aggregate resource costs per owning team and rank the result so each team receives an accurate, reviewable bill.
Input
JSON object: { resources: [{ name, owner, monthlyCost }] }Output
JSON array of { owner, monthlyCost } sorted by cost desc, then ownerSample tests
Sample 1
Input: {"resources":[{"name":"db","owner":"platform","monthlyCost":420.5},{"name":"cache","owner":"platform","monthlyCost":79.5},{"name":"cdn","owner":"web","monthlyCost":120}]}Expected: [{"owner":"platform","monthlyCost":500},{"owner":"web","monthlyCost":120}]Sample 2
Input: {"resources":[{"name":"cdn","owner":"web","monthlyCost":120},{"name":"batch","owner":"data","monthlyCost":120}]}Expected: [{"owner":"data","monthlyCost":120},{"owner":"web","monthlyCost":120}]Your solution
Learning objective
Produce a per-owner cost report that survives finance review.