FFIVE
您想要计算百分比增加。% 增加 = [(新值 - 原始值) / 原始值] * 100const increasePercentage = (n, m) => (m - n) / n * 100let a = [120, 148, 50]let b = [90, 100, 150] let c = a.map((n, i) => increasePercentage(n, b[i]))console.log(c); // [ -25%, -32.43%, 200% ]如果要计算 PEPEGA 提到的百分比差异,只需更改公式即可。% 差异 = [(新值 - 原始值) / ((新值 + 原始值) / 2)] * 100const increaseValue = (n, m) => (m - n) / ((m + n) / 2) * 100let a = [120, 148, 50]let b = [90, 100, 150] let c = a.map((n, i) => increaseValue(n, b[i]))console.log(c); // [ -28.57%, -38.71%, 100% ]