← Back to challenges

Percentage Changed

JavaScriptHardmath

Instructions

Create a function that takes an old price oldPrice, a new price newPrice, and returns what percent the price decreased or increased. Round the percentage to the nearest whole percent.

Examples

percentageChanged("$800", "$600") ➞ "25% decrease"

percentageChanged("$1000", "$840") ➞ "16% decrease"

percentageChanged("$100", "$950") ➞ "850% increase"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Functioninator 8000