i was trying to add comma to the string after every third character.
my code looks like this
var str = "12345678912345"
for (index,item) in str.enumerated() {
if index % 3 == 0 {
str.insert(",", at: str.index(of: item)!)
}
}
print(str)
i expect the output "123,456,789,123,45" but the actual output is ",123,,456,78912345".
i can't work with Int or Double and use NumberFormatter because input could be more than Int or Double max values.