How do I get from var x:number = 1200 to x = 1.200 or var x: number = 8 to x = 8.0 ?
            Asked
            
        
        
            Active
            
        
            Viewed 38 times
        
    -2
            
            
        - 
                    Can you explain why 1200 becomes 1.200 ? – Ian Jul 18 '22 at 10:27
- 
                    Does this answer your question? [javascript convert int to float](https://stackoverflow.com/questions/4057489/javascript-convert-int-to-float) – KusokBanana Jul 18 '22 at 10:43
- 
                    Is that dot a grouping char, or a decimal? – Hans Kesting Jul 18 '22 at 11:08
- 
                    Possibly you want [How to format numbers](https://stackoverflow.com/questions/5731193/how-to-format-numbers) – Hans Kesting Jul 18 '22 at 11:15
2 Answers
0
            
            
        actually, don't know what you want :
const conv = (num) => {
  arr = [...('' + num)] ;
  arr.splice(1, 0, '.')
  if (arr[arr.length-1] == '.') arr.push('0') ;
  return arr.join('')
}
console.log( conv(1200), conv(8) ) // 1.200 8.0
 
    
    
        Vivian K. Scott
        
- 515
- 2
- 5
- 13
 
    