I want to convert 1000000 to 1M also for 1000 To 1K
Any ideas?
I need it for my special project
I want to convert 1000000 to 1M also for 1000 To 1K
Any ideas?
I need it for my special project
You need to do the conversion from highest to lowest.
function convert(value)
{
if(value>=1000000)
{
value=(value/1000000)+"M"
}
else if(value>=1000)
{
value=(value/1000)+"K";
}
return value;
}
console.log(convert(1000));
console.log(convert(10000));
console.log(convert(300000));
console.log(convert(3000000));