So here's my problem: I've got a price that I'm pulling via AJAX, but what I'm pulling from doesn't add the last zero to the price if it ends in a zero. For example, something that is .40 cents will come back as .4. So now I'm trying to find a way to target the div where the price is stored, split the price at the period, and if the length of the cents column is less than 2, add a zero to the price. That's the code I need. Here's the code I have.
var split4 = $('#price selling4').text();
var arr4 = split4.split('.');
if (arr4[2] < 2) {
$("#price selling4").append("0")
}
I said it before and I'll say it again: I'm not the brightest programmer. But from my googling this seems to be what I'm looking for. However, whenever plugged in to console it does nothing. The append by itself doesn't even work. And the variables come back as undefined. Not really sure what else I can do with this by myself.