1
How to use substring in React Native?
if (total >= 1000){
const total2 = total.substr(total.lenght - 3, total.lenght);
total = total2 + '.' + total.substr(total.lenght - (total.lenght - 1), total.lenght - 3);
}
Error:
Undefined is not a Function (evaluating 'total.substr(total.lenght - 3, total.lenght);')
My intention is to check if the value is greater than or equal to 1000, divide the string into two parts and put the point in the third house backwards: 1,000
total.toString().substr(total.lenght - 3, total.lenght);
as you can see, it’s converting to string for the methodsubstr
is for string. String.prototype.substr()– NoobSaibot
I’m starting with React Native, but as far as I know, it uses javascript and it has no variable typing. My intention really is to take the total number and treat it as string. Tomorrow I will try to convert to see if it resolves
– Italo Rodrigo