I want to find the percentage of increase or decrease comparing 2 number, the second statement worked, but my test3 has failed if the second number is zero.
const test = Math.abs(((120 - 0) / 0) * 100).toFixed(1) + '%'
const test2 = Math.abs(((50 - 25) / 25) * 100).toFixed(1) + '%'
const test3 = Math.abs(((10000 - 0) / 0) * 100).toFixed(1) + '%'
console.log('test:', test)
console.log('test2:', test2)
console.log('test3', test3)
https://jsfiddle.net/vm1vsf6p/
How to solve this issue?