JAVASCRIPT   26

to-int

Guest on 1st May 2022 04:32:56 PM

  1. import absFloor from './abs-floor';
  2.  
  3. export default function toInt(argumentForCoercion) {
  4.     var coercedNumber = +argumentForCoercion,
  5.         value = 0;
  6.  
  7.     if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  8.         value = absFloor(coercedNumber);
  9.     }
  10.  
  11.     return value;
  12. }

Raw Paste


Login or Register to edit or fork this paste. It's free.