Using a crypto API I'm receiving the top currencies in the last 24 hours and their price in bitcoin. I want to round that price within my for loop.
So Im trying to Round the "+result.coins[i].item.price_btc+
" value
This number here is way to long and I want to round it [1]: https://i.stack.imgur.com/IxJfR.png
const coinTrending = "https://api.coingecko.com/api/v3/search/trending";
$.getJSON(coinTrending, function(result){
for(var i = 0; i < result.coins.length; i++){
console.log("Local Time");
//variable for html
var TopCur = `
<div class="p-2 h-full bg-gray-900 py-2 px-2 grid md:grid-cols-2 grid-cols-4 text-xs justify-items-center border-2 border-y-white">
<div class="text-center text-white text-base">`+result.coins[i].item.name+`</div>
<img src="`+result.coins[i].item.small+`" class="w-7 h-7 bg-white rounded-full"></img>
<div class="py-2 text-white">Market Cap:</div>
<div class="py-2 text-white">`+result.coins[i].item.market_cap_rank+`</div>
<div class="py-2 text-white">Bitcoin Price</div>
<div class="py-2 text-white">`+result.coins[i].item.price_btc+`</div>
</div>
`;
//add html to dom
$(".TopCurrencies").append(TopCur);
};
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>