Menu

1 / 2

Demystifying ROI and CAGR with five JavaScript snippets

DEV Community·levent çelik·7 months ago
#AqotNARN
Reading 0:00
15s threshold

Two acronyms cause more confusion in product analytics meetings than any others I know: ROI and CAGR. They sound interchangeable in slides, they look interchangeable in spreadsheets, and they are absolutely not the same thing. After watching one too many "the experiment had 200% ROI" claims fall apart on a closer read, I sat down and wrote out the actual formulas in code. Here they are.

ROI: the simple one

Return on Investment is just net gain divided by cost.

function roi ({ gain , cost }) { return (( gain - cost ) / cost ) * 100 ; }

roi ({ gain : 1500 , cost : 1000 }); // 50

Enter fullscreen mode

Exit fullscreen mode

A $1,000 investment that returns $1,500 has a 50% ROI. Done. The trap people fall into is forgetting that this number is timeless. A 50% ROI over 1 year is amazing. A 50% ROI over 30 years is dismal (it loses to inflation by a wide margin).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.