I've been trying to limit the output data for 'priceChangePercent' to 2 decimal places but can't seem to get it working. Can anyone point me in the right direction?
Function
async function getPriceBTCUSDT() {
const response = await fetch("https://api.binance.com/api/v3/ticker/24hr?symbol=BTCUSDT");
const data = await response.json();
const {
prevClosePrice,
priceChangePercent
} = data;
if (priceChangePercent > 0) {
document.getElementById('24hr-btcusdt').style.color = 'green'
}
document.getElementById('price-btcusdt').textContent = prevClosePrice;
document.getElementById('24hr-btcusdt').textContent = priceChangePercent + "%";
}
getPriceBTCUSDT();
setInterval(getPriceBTCUSDT, 3000);
<span id="price-btcusdt"></span>
<span id="24hr-btcusdt"></span>