I am getting passed numbers like 01,02,03,04 and up. And I would like to remove the prefixed 0
from them if it exists. But I need it to leave numbers like 10, 20, 30 as they are.
My latest attempt of which I think is overkill as is.. is:
newValue = 01;
tester(newValue);
newValue = 10;
tester(newValue);
function tester(newValue)
{
finalValue = newValue;
var arr = newValue.split('0');
if(arr.length > 1)
{
if(arr[0] == 0)
{
finalValue = '';
$.each(arr, function(v)
{
finalValue +=v;
});
}
}
//return finalValue;
console.log(finalValue);
}
Im not sold on this method, I've just tried a number of ways and its all be no go.