Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

best way to round to two typescript

const roundTo = function(num: number, places: number) {
  const factor = 10 ** places;
  return Math.round(num * factor) / factor;
};

roundTo(123.456, 2);  // 123.46
roundTo(123.3210, 2);  // 123.32
roundTo(123.456, 1);  // 123.5
roundTo(123, 2);  // 123
Comment

PREVIOUS NEXT
Code Example
Typescript :: mat-sort not working in dynamically generated table 
Typescript :: typescript object to array 
Typescript :: typescript webpack node 
Typescript :: pdf viewer ionic 4 
Typescript :: Check if value exisits update or insert sQL 
Typescript :: how to declare variable in typescript 
Typescript :: Cannot show Automatic Strong Passwords for app bundleID: com.williamyeung.gameofchats due to error: iCloud Keychain is disabled 
Typescript :: NullInjectorError: R3InjectorError(DynamicTestModule)[AdminTestCentersComponent - ToastrService - InjectionToken ToastConfig - InjectionToken ToastConfig]: NullInjectorError: No provider for InjectionToken ToastConfig! 
Typescript :: google sheets sumif 
Typescript :: mixed array typescript 
Typescript :: add active class when element exists into an array vuejs 
Typescript :: An attempt was made to access a socket in a way forbidden by its access permissions. 
Typescript :: react typescript create react app 
Typescript :: common mistakes in testing 
Typescript :: find unique values between 2 lists R 
Typescript :: convert node to typescript 
Typescript :: typescript component props 
Typescript :: ts generics 
Typescript :: typescript check type 
Typescript :: hide elements in 2s jquery 
Typescript :: loop two lists python 
Typescript :: typescript namespace 
Typescript :: react onclick action starts automatically 
Typescript :: Fill in the right keywords to test the conditions: 
Typescript :: enums in typescript 
Typescript :: angular from date to date validation 
Typescript :: nodejs stream write file 
Typescript :: regex exec returns null 
Typescript :: typescript add object to object 
Typescript :: type async function typescript 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =