I\'m trying to write a function to present thousands and millions into K\'s and M\'s For instance:
1000 = 1k
1100 = 1.1k
15000 = 15k
115000 = 115k
1000000 =
Some Change in Answer(For Int and correct for million):
func formatPoints(num: Int) ->String{
let thousandNum = num/1000
let millionNum = num/1000000
if num >= 1000 && num < 1000000{
if(thousandNum == thousandNum){
return("\(thousandNum)k")
}
return("\(thousandNum)k")
}
if num > 1000000{
if(millionNum == millionNum){
return("\(millionNum)M")
}
return ("\(millionNum)M")
}
else{
if(num == num){
return ("\(num)")
}
return ("\(num)")
}
}