Calculate the percentage difference between two numbers.
The result is how many percent the larger value exceeds the smaller one: percentDiff(100, 150) === 50, percentDiff(150, 100) === 50.
Edge cases are reported honestly instead of a sentinel value:
The first number.
The second number.
The percentage difference between the two numbers.
Calculate the percentage difference between two numbers.
The result is how many percent the larger value exceeds the smaller one: percentDiff(100, 150) === 50, percentDiff(150, 100) === 50.
Edge cases are reported honestly instead of a sentinel value: