Libraries

  • Math.ceil()

      • The Math.ceil() function returns the smallest integer greater than or equal to a given number.
      • console.log(Math.ceil(.95));
        // expected output: 1
        
        console.log(Math.ceil(4));
        // expected output: 4
        
        console.log(Math.ceil(7.004));
        // expected output: 8
        
        console.log(Math.ceil(-7.004));
        // expected output: -7
        
  • Number.isInteger()

    •   The Number.isInteger() method determines whether the passed value is an integer.
    • function fits(x, y) {
        if (Number.isInteger(y / x)) {
          return 'Fits!';
        }
        return 'Does NOT fit!';
      }
      
      console.log(fits(5, 10));
      // expected output: "Fits!"
      
      console.log(fits(5, 11));
      // expected output: "Does NOT fit!"
      
永远渴望,大智若愚(stay hungry, stay foolish)
原文地址:https://www.cnblogs.com/h-hkai/p/8672279.html