Is there a way to adjust the numerical data returned by the API to display only two decimal places instead of three? For example, if the number is 140.444, I want it to show as 140.44
What changes do I need to make?
function fetchData() {
fetch("https://www.dolarsi.com/api/api.php?type=valoresprincipales")
.then((response) => {
return response.json();
})
.then((data) => {
const filteredOutput = data.filter((item) => {
switch (item.casa.nombre) {
case "Dolar Blue":
return item;
break;
default:
return null;
}
});
let html = "";
filteredOutput.forEach((item) => {
html +=
'<p class= "venta"> <small class= "ventaPrecio">VENTA</small><span</span><br> $ ' +
parseFloat(item.casa.venta).toFixed(2) +
"</p>";
});
document
.querySelector("#blueVenta")
.insertAdjacentHTML("afterbegin", html);
});
}
fetchData();