Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript change long digit ot k,m

function nFormatter(num) {
     if (num >= 1000000000) {
        return (num / 1000000000).toFixed(1).replace(/.0$/, '') + 'G';
     }
     if (num >= 1000000) {
        return (num / 1000000).toFixed(1).replace(/.0$/, '') + 'M';
     }
     if (num >= 1000) {
        return (num / 1000).toFixed(1).replace(/.0$/, '') + 'K';
     }
     return num;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery get first character of string 
Javascript :: data-dismiss= modal in jquery 
Javascript :: useHistory is not exported form react-router-dom 
Javascript :: noconflict jquery 
Javascript :: how to find the key of an value in an object 
Javascript :: javascript get last character in string 
Javascript :: pattern telefone js 
Javascript :: moment format 23 hour 
Javascript :: Check if a JavaScript string is a URL 
Javascript :: remove negative sign from number javascript 
Javascript :: nextjs create project with tailwind 
Javascript :: coldfusion user defined function 
Javascript :: how to copy text in react 
Javascript :: javascript truncate with ellipsis 
Javascript :: javascript code to loop through array 
Javascript :: onclick cloSe tab in jquery 
Javascript :: javascript loop through object values 
Javascript :: Hide elements until Alpine Js loads 
Javascript :: how to check data type of javascript variable 
Javascript :: get age by birthday js 
Javascript :: js reduce concat numbers 
Javascript :: javascript get width of a div 
Javascript :: jest setImmediate is not defined 
Javascript :: document ready without jquery 
Javascript :: Get Substring between two characters using javascript 
Javascript :: javascript keywords 
Javascript :: js xmlhttprequest add header 
Javascript :: google charts hide legend 
Javascript :: write files in node js 
Javascript :: c# get value from json object 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =