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

1 Answer

0 votes
let x = 9382.4;
let y = Math.round(x);
console.log(y);

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

  
  
/*
run:
  
9382
9383
  
*/

 



answered May 14, 2025 by avibootz
...