Skip to content

Add return on investment to math algorithms#2178

Open
InukaWijerathna wants to merge 1 commit into
trekhleb:masterfrom
InukaWijerathna:add/return-on-investment
Open

Add return on investment to math algorithms#2178
InukaWijerathna wants to merge 1 commit into
trekhleb:masterfrom
InukaWijerathna:add/return-on-investment

Conversation

@InukaWijerathna
Copy link
Copy Markdown

Description

Adds Return on Investment (ROI) to the math category.

ROI is a foundational financial formula that measures how profitable an investment was relative to what you put in — it shows up in everything from business analysis to personal finance:

ROI = (Gain from Investment - Cost of Investment) / Cost of Investment × 100

What's included

  • src/algorithms/math/return-on-investment/ReturnOnInvestment.js — clean implementation, throws on invalid cost
  • src/algorithms/math/return-on-investment/__test__/ReturnOnInvestment.test.js — 6 test cases covering all branches
  • src/algorithms/math/return-on-investment/README.md — explanation, formula table, and reference

Checklist

  • Follows the repo's directory and file naming conventions
  • Jest tests for positive/zero/negative ROI and error cases
  • README with formula, examples table, and Investopedia reference

Reference: https://www.investopedia.com/terms/r/returnoninvestment.asp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant