How to use floor to get the closest integer which is less than or equal to specified value in Node.js

1 Answer

0 votes
console.log(Math.floor(5)); 
console.log(Math.floor(5.14)); 
console.log(Math.floor(5.4)); 
console.log(Math.floor(5.5)); 
console.log(Math.floor(5.6)); 
console.log(Math.floor(5.99)); 

console.log(Math.floor(-5)); 
console.log(Math.floor(-5.14)); 
console.log(Math.floor(-5.4)); 
console.log(Math.floor(-5.5)); 
console.log(Math.floor(-5.6)); 
console.log(Math.floor(-5.99)); 
          
     
     
   
/*
run:
   
5
5
5
5
5
5
-5
-6
-6
-6
-6
-6

*/

 



answered Aug 7, 2022 by avibootz
...