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

1 Answer

0 votes
console.log(Math.floor(3)); 
console.log(Math.floor(3.14)); 
console.log(Math.floor(3.4)); 
console.log(Math.floor(3.5)); 
console.log(Math.floor(3.6)); 
console.log(Math.floor(3.99)); 

console.log(Math.floor(-3)); 
console.log(Math.floor(-3.14)); 
console.log(Math.floor(-3.4)); 
console.log(Math.floor(-3.5)); 
console.log(Math.floor(-3.6)); 
console.log(Math.floor(-3.99)); 
          
     
     
   
/*
run:
   
3
3
3
3
3
3
-3
-4
-4
-4
-4
-4
   
*/

 



answered May 7, 2019 by avibootz
edited Aug 7, 2022 by avibootz
...