Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery number format thousand k

function kFormatter(num) {
    return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num)
}
    
console.log(kFormatter(1200)); // 1.2k
console.log(kFormatter(-1200)); // -1.2k
console.log(kFormatter(900)); // 900
console.log(kFormatter(-900)); // -900
Comment

PREVIOUS NEXT
Code Example
Javascript :: cypress multiple true 
Javascript :: s3 private image getobject react js 
Javascript :: format date in javascript 
Javascript :: generate uuid from string js 
Javascript :: get parameter from url using jquery 
Javascript :: for of loop 
Javascript :: days in the current month 
Javascript :: window scroll top 
Javascript :: bson to json converter 
Javascript :: jquery: get selected option of the drop down list 
Javascript :: javascript lowest number 
Javascript :: how to export a function in nodejs 
Javascript :: javascript regex stop at first match 
Javascript :: javascript declare string in multiple lines 
Javascript :: scroll load react 
Javascript :: how to disable right click of mouse on web page 
Javascript :: scroll value bottom js 
Javascript :: get param is react 
Javascript :: execcommand javascript 
Javascript :: react native get os 
Javascript :: get index in map javascript 
Javascript :: exit foreach loop js 
Javascript :: twilio sms sending in express 
Javascript :: react-select 
Javascript :: check fpr multiple values in an array jquery 
Javascript :: class constructor javascript 
Javascript :: javascript parsestring 
Javascript :: http header express 
Javascript :: reverse sort array of objects 
Javascript :: get url of website javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =