How to round a floating-point number to an integer in TypeScript

1 Answer

0 votes
let x: number = 7691.4;
let y: number = Math.round(x);
console.log(y);

x = 7691.5;
y = Math.round(x);
console.log(y);

  
  
/*
run:
  
7691 
7692
  
*/
 

 



answered May 14 by avibootz
...