For percent increase and decrease, using 2 different methods:
const a = 541
const b = 394
// Percent increase
console.log(
`Increase (from ${b} to ${a}) => `,
(((a/b)-1) * 100).toFixed(2) + "%",
)
// Percent decrease
console.log(
`Decrease (from ${a} to ${b}) => `,
(((b/a)-1) * 100).toFixed(2) + "%",
)
// Alternatives, using .toLocaleString()
console.log(
`Increase (from ${b} to ${a}) => `,
((a/b)-1).toLocaleString('fullwide', {maximumFractionDigits:2, style:'percent'}),
)
console.log(
`Decrease (from ${a} to ${b}) => `,
((b/a)-1).toLocaleString('fullwide', {maximumFractionDigits:2, style:'percent'}),
)
_x000D_