Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js remove zeros after decimal

(+n).toFixed(2).replace(/(.0+|0+)$/, '')


// 0 => 0
// 0.1234 => 0.12
// 0.1001 => 0.1

// 1 => 1
// 1.1234 => 1.12
// 1.1001 => 1.1

// 100 => 100
// 100.1234 => 100.12
// 100.1001 => 100.1

Comment

remove 0 after decimal point in javascript

const s = 1.245000  
const noZeroes = s.toString()  

// 1.245
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs express api 
Javascript :: material ui select helper text 
Javascript :: js conditional array element 
Javascript :: binary search in js 
Javascript :: javascript download string as file 
Javascript :: how to return character associated to character code javascript 
Javascript :: console log state object redux 
Javascript :: component unmount useeffect 
Javascript :: javascript interview preparation 
Javascript :: how to pass props in gatsby link using styledcomponent 
Javascript :: change event listener in javascript 
Javascript :: jquery merge objects 
Javascript :: get full date in javascript 
Javascript :: new line in js 
Javascript :: javascript truncate string full word 
Javascript :: meteor update package 
Javascript :: send data through routes in react 
Javascript :: json data doesn show on console 
Javascript :: react native open phone 
Javascript :: jquery clear form values 
Javascript :: how To clear all the input element inside div using jquery 
Javascript :: jquery remove style 
Javascript :: display current date and time in react js 
Javascript :: angular local storage 
Javascript :: iterate object keys javascript 
Javascript :: Detecting a mobile browser 
Javascript :: style font size javascript 
Javascript :: html javascript call function after pressing enter 
Javascript :: javascript paragraph count 
Javascript :: javascript use camera 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =